Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to get user current opened application?
    primarykey
    data
    text
    <p>I am looking for a solution that i would like to get user opened or installed application on his device.I have to get which app opened by user from my BroadcastReceiver class.I have implemented my code as follows:</p> <pre><code>public class AppReceiver extends BroadcastReceiver{ @Override public void onReceive(Context context, Intent intent) { ActivityManager am = (ActivityManager)context.getSystemService(context.ACTIVITY_SERVICE); List l = am.getRunningAppProcesses(); Iterator i = l.iterator(); PackageManager pm = context.getPackageManager(); while(i.hasNext()) { ActivityManager.RunningAppProcessInfo info = (ActivityManager.RunningAppProcessInfo)(i.next()); try { CharSequence c = pm.getApplicationLabel(pm.getApplicationInfo(info.processName, PackageManager.GET_META_DATA)); Log.v(" App Name : ", c.toString()); }catch(Exception e) { } } } </code></pre> <p>I have also added about this reciever on manifest file as :</p> <pre><code> &lt;receiver android:name="AppReciever"&gt; &lt;intent-filter&gt; &lt;category android:name="android.intent.category.DEFAULT" /&gt; &lt;action android:name="android.intent.action.PACKAGE_ADDED"&gt;&lt;/action&gt; &lt;action android:name="android.intent.action.PACKAGE_CHANGED"&gt;&lt;/action&gt; &lt;action android:name="android.intent.action.PACKAGE_INSTALL"&gt;&lt;/action&gt; &lt;action android:name="android.intent.action.PACKAGE_REPLACED"&gt;&lt;/action&gt; &lt;action android:name="android.intent.action.PACKAGE_RESTARTED"&gt;&lt;/action&gt; &lt;data android:scheme="package" /&gt; &lt;/intent-filter&gt; &lt;/receiver&gt; </code></pre> <p>From the above code AppReciver not executing for get the app name at Log.v when I opened new app which are already existed(installed) on the device.It is working for only once other app run on device.</p> <p>Please any body help me on get the current opened applications from BroadcastReceiver</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload