我正在創建一個應用程序來發送郵件。我正在使用擴展phoneStateListener類的類。這給出了startActivity函數時的問題,它說「方法startActivity(Intent)對於PhoneCallListener類型是未定義的」,其中PhoneCallListener是由phonestatelistener擴展的類,並將以下代碼寫入其中。如何從phoneStateListener類調用startActivity(intent)?
String to = "[email protected]";
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 :"));
請幫助我如何開始活動,以發送我的郵件。
你還挺需要一個環境來開始一項活動。 – njzk2