I want to start launch facebook
from my application I have tried the below code
public void text(String MessageBody) {
public void text(String MessageBody) {
try {
Toast.makeText(getApplicationContext(), "salam its working", Toast.LENGTH_LONG).show();
PackageManager pm = getPackageManager();
if(MessageBody=="facebook") {
Intent intent = pm.getLaunchIntentForPackage("com.android.camera");
startActivity(intent);
}
} catch(Exception e) {
Toast.makeText(getApplicationContext(), e.toString(), Toast.LENGTH_LONG).show();
}
}
This is working fine from activity class but I am looking for a way to run the same code in non-activity class.
there was error of context ,now its working in when i start activity method in non activity class
Context c;
Toast.makeText(context, message1, Toast.LENGTH_LONG).show();
PackageManager pm = context.getPackageManager();
Intent intentt =pm.getLaunchIntentForPackage("com.facebook.katana");
context.startActivity(intentt);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.