0
だから私はアンドロイドがかなり新しく、ボタンを作成して通知を作成し、この通知をクリックすると電話がかかります。私はオンラインで多くのことをしてきましたが、これがなぜ機能していないのかまだ分かりません。私はこの方法を持っています。保留中のインテントで通知を作成する
public void notification(){
Intent callIntent = new Intent(Intent.ACTION_CALL);
callIntent.setData(Uri.parse("tel: 0210000001"));
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, callIntent, PendingIntent.FLAG_UPDATE_CURRENT);
android.support.v4.app.NotificationCompat.Builder mBuilder =
new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.ic_stat_name)
.setContentTitle("My notification")
.setContentText("Click to ring 021 000 0001")
.setContentIntent(pendingIntent);
}
このメソッドを呼び出すボタンです。
Button notif = (Button) findViewById(R.id.notificationButton);
notif.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
notification();
}
});}
ご協力いただければ幸いです。
このドキュメントは次のとおりです。https://developer.android.com/training/notify-user/build-notification.html –