title: How to get the starting time of an app in android
body: <p>I create an android application, i have to create a notification about apps running in background with there staring time, i'll successfully get the running apps but cant generate that the app is running from how long time. For example-> Talking Tom is running from last 3 hours etc.</p>
  
  <p>public class ListAdapter extends ArrayAdapter  {</p>
  
  <pre><code>// List context
  private final Context context;
  
  // List values
  private final List&lt;RunningAppProcessInfo&gt; values;
  
  public ListAdapter(Context context, List&lt;RunningAppProcessInfo&gt; values) {
      super(context, R.layout.activity_main, values);
      this.context = context;
      this.values = values;
  }
  
  /**
   * Constructing list element view
   */
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
      long re = MainActivity.recived;
      long sd = MainActivity.send;
      System.out.println("hii");
      long po=MainActivity.pos;
  /*    if(position!=po)
          return null;   */
      LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  
      View rowView = inflater.inflate(R.layout.activity_main, parent, false);
  
      TextView appName = (TextView) rowView.findViewById(R.id.appNameText);
      appName.setText(values.get(position).processName);
  
      TextView sendtxt = (TextView) rowView.findViewById(R.id.sendtv);
      sendtxt.setText(String.valueOf(re/1024));
  
    //  sendtxt.setText(b1.getString("passed2"));
      TextView receivetxt = (TextView) rowView.findViewById(R.id.receivetv);
      receivetxt.setText(String.valueOf(sd/1024));
  
    //  receivetxt.setText(b1.getString("passed1"));
  
      return rowView;
  
  }  
  </code></pre>
  
  <p>}</p>
  
  <p>MY SECOND CLASS IS:-></p>
  
  <p>public class ApplicationAdapter extends ArrayAdapter {</p>
  
  <pre><code> private List&lt;ApplicationInfo&gt; appsList = null;
      private Context context;
      private PackageManager packageManager;
  
      public ApplicationAdapter(Context context, int textViewResourceId,
              List&lt;ApplicationInfo&gt; appsList) {
          super(context, textViewResourceId, appsList);
          this.context = context;
          this.appsList = appsList;
          packageManager = context.getPackageManager();
      }
  
      @Override
      public int getCount() {
          return ((null != appsList) ? appsList.size() : 0);
      }
  
      @Override
      public ApplicationInfo getItem(int position) {
          return ((null != appsList) ? appsList.get(position) : null);
      }
  
      @Override
      public long getItemId(int position) {
          return position;
      }
  
      @Override
      public View getView(int position, View convertView, ViewGroup parent) {
          View view = convertView;
          if (null == view) {
              LayoutInflater layoutInflater = (LayoutInflater) context
                      .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
              view = layoutInflater.inflate(R.layout.snippet, null);
          }
  
          ApplicationInfo data = appsList.get(position);
          if (null != data) {
              TextView appName = (TextView) view.findViewById(R.id.app_name);
              TextView packageName = (TextView) view.findViewById(R.id.app_paackage);
              ImageView iconview = (ImageView) view.findViewById(R.id.app_icon);
  
              appName.setText(data.loadLabel(packageManager));
              packageName.setText(data.packageName);
              iconview.setImageDrawable(data.loadIcon(packageManager));
          }
          return view;
      }
  };
  </code></pre>