Intent launchFacebookApplication=getApplicationContext().getPackageManager().getLaunchIntentForPackage("com.google.android.apps.messaging");
launchFacebookApplication.addCategory(Intent.ACTION_MAIN);
startActivity(launchFacebookApplication);
or
ComponentName compName=new ComponentName("com.google.android.apps.messaging","com.google.android.apps.messaging");
Intent intent=new Intent(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_LAUNCHER);
//intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setComponent(compName);
startActivity(intent);
and in manifest:-
<queries>
<package android:name="com.google.android.apps.messaging"/>
</queries>
and getting error:-
PID: 2824
android.content.ActivityNotFoundException: Unable to find explicit activity class {com.google.android.apps.messaging/com.google.android.apps.messaging}; have you declared this activity in your AndroidManifest.xml?
any wrong in this code , please help me out in this issue
There is no promise that an app named "com.google.android.apps.messaging" exists. OEMs and users can and do replace the default SMS app. OEMs sometimes ship without Google's SMS app. If you want to send an sms, use SMSManager or launch it with a generic texting intent. Check launch sms application with an intent or How to open sms app via implicit intent? And ignore any of the old bad answers that set a component name.
Also, if you were trying to launch Facebook like your variable name says- that's not the name of the Facebook app. Which is also not assured to be installed.