How can i use compose email activity in tabView?

旧街凉风 提交于 2019-12-20 05:43:22

问题


I want to display compose email in Tab Activity. It is my code.

        TabHost tabHost=getTabHost();
    TabHost.TabSpec spec;
    Intent intent;

    //View tabView= tabHost.getChildAt(0);
    //tabView.setPadding(0, 13, 0, 13);
    //tabView.setBackgroundColor(0xFFFFFFFF);
    intent=new Intent("com.android.phone.action.RECENT_CALLS").setClass(this,CallListActivity.class);
    spec=tabHost.newTabSpec("Call").setIndicator("Call").setContent(intent);
    tabHost.addTab(spec);

    intent=new Intent("android.intent.action.Compose_EMAIL");
    intent.setClassName("com.android.email", "com.android.email.activity.MessageCompose");
    spec=tabHost.newTabSpec("Message").setIndicator("Message").setContent(intent);
    tabHost.addTab(spec);    

    intent=new Intent().setClass(this, com.android.contacts.qs.logger.email.QsEmailLogger.class);
    spec=tabHost.newTabSpec("Email").setIndicator("Email").setContent(intent);
    tabHost.addTab(spec);

    intent=new Intent().setClass(this,com.android.contacts.qs.logger.notification.NotificationLogger.class);
    spec=tabHost.newTabSpec("Notification").setIndicator("Notification").setContent(intent);
    tabHost.addTab(spec);                      

    tabHost.setCurrentTab(0);

This code is generate Error. Error is 03-16 12:04:09.132: E/AndroidRuntime(312): java.lang.SecurityException: Requesting code from com.android.email (with uid 10011) to be run in process android.process.acore (with uid 10001)

   intent=new Intent("android.intent.action.Compose_EMAIL");
    intent.setClassName("com.android.email", "com.android.email.activity.MessageCompose");
    spec=tabHost.newTabSpec("Message").setIndicator("Message").setContent(intent);
    tabHost.addTab(sp

回答1:


In your Application Manifest write the below lines,

android:sharedUserId="android.uid.shared"
android:sharedUserLabel="@string/sharedUserLabel"

The sharedUserId parameter is used to share the code,process,data between two apps. So thes code will apply in both the apps.

and also write these lines in your .mk file of both the apps...

LOCAL_CERTIFICATE := shared



回答2:


on tab button click you can call a method

        tv_email.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {

                sendSimpleEmail(tv_email);
            }
        });        

this is a method which is used to open a compose email window ,call this method onClick

  public void sendSimpleEmail(View textView) {
    try {

  Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
        emailIntent.setType("plain/text");

        emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL,
                new String[] { email_add });
        startActivity(emailIntent);
    } catch (Exception e) {

        Toast.makeText(getApplicationContext(),
                "First Log in to your Email Account", Toast.LENGTH_LONG)
                .show();
    }
}


来源:https://stackoverflow.com/questions/9732999/how-can-i-use-compose-email-activity-in-tabview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!