Answer the question
In order to leave comments, you need to log in
(Question for android gurus) Why doesn't the curtain collapse when you click on the button in the custom notification?
In general, I made my big Notification, added a button there that opens the activity with settings, but the problem is that I click on the button, the activity opens in the background, but the curtain does not collapse, it must be manually collapsed. How can I make it collapse when the button in the notification is clicked?
The handler is made like this, there is a class
public static class MyButtonListener extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
switch (intent.getStringExtra("element")){
case "SETTINGS":
intent = new Intent(context,SettingsActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);//МОЖЕТ НУЖНО ДРУГОЙ\ДОПОЛНИТЕЛЬНЫЙ ФЛАГ?
context.startActivity(intent);//ВОТ ТУТ ВЫЗЫВАЕТСЯ АКТИВИТИ С НАСТРОЙКАМИ
break;
case "EYE":
break;
case "SOUND":
break;
}
}
}
<receiver android:name=".ServiceNotification$MyButtonListener" />
Intent myIntent = new Intent(this, MyButtonListener.class);
myIntent.putExtra("element","SETTINGS");
PendingIntent pendingMyIntent = PendingIntent.getBroadcast(this, 0, myIntent, PendingIntent.FLAG_UPDATE_CURRENT);
expandedView.setOnClickPendingIntent(R.id.notif_btn_settings, pendingMyIntent);
Answer the question
In order to leave comments, you need to log in
Got it! I'll answer my own question, maybe someone will need it.
To set an event on your buttons in your custom Big Notification. This design should be used.
Intent tt = new Intent(this, SettingsActivity.class);
TaskStackBuilder ss = TaskStackBuilder.create(this);
stackBuilder.addParentStack(MainActivity.class);
stackBuilder.addNextIntent(tt);
PendingIntent rr = stackBuilder.getPendingIntent(
0, PendingIntent.FLAG_UPDATE_CURRENT);
expandedView.setOnClickPendingIntent(R.id.notif_btn_settings, rr);
//notif_btn_settings - ид Кнопки, expandedView это мой RemoteViews
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question