【问题标题】:How can i use compose email activity in tabView?如何在 tabView 中使用撰写电子邮件活动?
【发布时间】:2012-03-16 06:39:28
【问题描述】:

我想在选项卡活动中显示撰写电子邮件。这是我的代码。

        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: Requesting code from com.android.email (with uid 10011) to be run in process 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

【问题讨论】:

    标签: java android android-layout mobile


    【解决方案1】:

    在您的应用程序清单中写下以下几行,

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

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

    并将这些行写入两个应用程序的 .mk 文件中...

    LOCAL_CERTIFICATE := shared
    

    【讨论】:

      【解决方案2】:

      在tab按钮上点击可以调用方法

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

      这是一个用来打开写邮件窗口的方法,在点击时调用这个方法

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

      【讨论】:

      • 我正在研究 Ginger Bread 源代码。我想在 Contact 包中调用 MeassageCompose.java 活动。我正在修改核心电子邮件功能,为什么我不能使用这个消息。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-01-16
      • 2015-01-20
      • 1970-01-01
      • 2014-09-02
      • 2016-05-02
      相关资源
      最近更新 更多