How to open and show phone's message inbox programmatically..?

前端 未结 4 928
一生所求
一生所求 2021-01-26 23:19

When we click on messages we are showed with the inbox.

I want to show the same window when i clicked on my application\'s button.

So, I want to start message in

4条回答
  •  感动是毒
    2021-01-26 23:55

    Try this.. works perfectly..!

    public void openInbox() {
    String application_name = "com.android.mms";
    try {
    Intent intent = new Intent("android.intent.action.MAIN");
    intent.addCategory("android.intent.category.LAUNCHER");
    
    intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
    List resolveinfo_list = this.getPackageManager()
    .queryIntentActivities(intent, 0);
    
    for (ResolveInfo info : resolveinfo_list) {
    if (info.activityInfo.packageName
    .equalsIgnoreCase(application_name)) {
    launchComponent(info.activityInfo.packageName,
    info.activityInfo.name);
    break;
    }
    }
    } catch (ActivityNotFoundException e) {
    Toast.makeText(
    this.getApplicationContext(),
    "There was a problem loading the application: "
    + application_name, Toast.LENGTH_SHORT).show();
    }
    }
    
    private void launchComponent(String packageName, String name) {
    Intent launch_intent = new Intent("android.intent.action.MAIN");
    launch_intent.addCategory("android.intent.category.LAUNCHER");
    launch_intent.setComponent(new ComponentName(packageName, name));
    launch_intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    this.startActivity(launch_intent);
    }
    

提交回复
热议问题