2012-03-16 56 views
0

我想在选项卡活动中显示撰写电子邮件。这是我的代码。如何在tabView中使用撰写电子邮件活动?

 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 

回答

1

在你的应用程序清单编写下面线,

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

的sharedUserId参数用于共享代码,过程,两个应用程序之间的数据。 因此,这些代码将适用于这两个应用程序。

,也写这些线路在两个应用程序的.mk文件...

LOCAL_CERTIFICATE := shared 
1

点击就可以调用一个方法

 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(); 
    } 
} 
+0

我是姜饼源代码的工作。我想在联系包中调用MeassageCompose.java活动。我正在修改核心电子邮件功能,为什么我不能使用这个meassage。 – 2012-03-16 11:58:38

相关问题