androidアプリ開発を勉強し始めたばかりです
まず、notificationを使いたいと思い、解説本からコピペして実行すると、Botton時点で「問題が発生したため~」と強制終了します。
どうしたら正常にnotificationが表示されるか教えてください。
logcatのエラーっぽい部分には以下の様に表示されました
E/AndroidRuntime(11099): java.lang.IllegalStateException: Could not find a method do Action(View) in the activity class com.example.ryosyou.MainActivity for onClick handler on view class android.widget.Button with id 'button1'
mainActivityの加筆部分
public void doAction(View view){
EditText edit1=(EditText)this.findViewById(R.id.editText1);
Editable s = edit1.getText();
Intent intent=new Intent(this,com.example.ryosyou.MainActivity.class);
PendingIntent pending=PendingIntent.getActivity(this, 1, intent,PendingIntent.FLAG_CANCEL_CURRENT);
Notification notify=new Notification();
notify.flags=Notification.FLAG_AUTO_CANCEL;
notify.icon=R.drawable.ic_launcher;
notify.tickerText="!Hello!";
notify.setLatestEventInfo(this, "Hello Info", "message:"+s , pending);
NotificationManager manager=(NotificationManager)this.getSystemService(Activity.NOTIFICATION_SERVICE);
manager.notify(1, notify);
}
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。