0

我正在创建一个应用程序来发送邮件。我正在使用扩展 phoneStateListener 类的类。这在 startActivity 函数时给出了问题,它表示“方法 startActivity(Intent) 未定义为 PhoneCallListener 类型”,其中 PhoneCallListener 是由 phonestatelistener 扩展的类,并且将以下代码写入其中。

          String to = "a.crack@gmail.com";
          String subject = "testing";
          String message = "this is it";
         Intent email = new Intent(Intent.ACTION_SEND);
          email.putExtra(Intent.EXTRA_EMAIL, new String[]{ to});

          email.putExtra(Intent.EXTRA_SUBJECT, subject);
          email.putExtra(Intent.EXTRA_TEXT, message);

          //need this to prompts email client only
          email.setType("message/rfc822");

              startActivity(Intent.createChooser(email, "Choose an Email client :"));

请帮助我如何开始活动以发送我的邮件。

4

1 回答 1

1
 public class MyPhoneReceiver extends BroadcastReceiver {
        Intent in;
            @Override
            public void onReceive(Context context, Intent intent) {
                Bundle extras = intent.getExtras();
                if (extras != null) {
                in = new Intent(context, Second.class);
                    in.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                    context.startActivity(in);

                }
            }
    }

确保在清单文件中添加接收器。

于 2012-10-31T21:09:38.330 回答