dimanche 29 mars 2015

ActivityNotFoundException not resolving



I want to open activity via broadcast receiver , i tried any ways , but i am getting ActivityNotFoundException , my activity is working on normal mode, but when i want to open it from BroadCastRecevier it cause ActivityNotFoundException error,


It is my manifest ,



<activity
android:excludeFromRecents="true"
android:launchMode="singleTask"
android:screenOrientation="portrait"
android:name="com.alexis.abc.ui.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>


And it is my broadcast receiver ,



Intent intent2 = new Intent(context, MainActivity.class);
intent2.addCategory("android.intent.category.LAUNCHER");
intent2.setAction("android.intent.action.MAIN");
context.startActivity(intent2);


Here is steps :

1 - I opening application and hiding launcher icon via following code



PackageManager packageManager = getContext().getPackageManager();
ComponentName componentName = new ComponentName(getContext(), MainActivity.class);
packageManager.setComponentEnabledSetting(componentName, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);


2 - I exiting to application and dialing a number (To triggering broadcast event) and i getting following exception



android.content.ActivityNotFoundException: Unable to find explicit activity class {http://ift.tt/1ESr3ib}; have you declared this activity in your AndroidManifest.xml?



Aucun commentaire:

Enregistrer un commentaire