如何在tabView中使用撰写电子邮件活动?

我想在Tab Activity中显示撰写电子邮件。 这是我的代码。

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); 

此代码生成错误。 错误是03-16 12:04:09.132:E / AndroidRuntime(312):java.lang.SecurityException:从com.android.email(使用uid 10011)请求代码在进程android.process.acore中运行(使用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 

在您的Application Manifest中写下以下行,

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

sharedUserId参数用于在两个应用程序之间共享代码,进程和数据。 所以这些代码将适用于这两个应用程序。

并在这两个应用程序的.mk文件中写下这些行…

 LOCAL_CERTIFICATE := shared 

在标签按钮上单击,您可以调用方法

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

这是一个用于打开撰写电子邮件窗口的方法,在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(); } }