2012-03-16 58 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

相關問題