Working Local notifications for system events.

This commit is contained in:
Brian Mwadime 2016-07-16 09:03:49 +03:00
Родитель ed7493501a
Коммит f93bcb5537
2 изменённых файлов: 10 добавлений и 4 удалений

Просмотреть файл

@ -88,33 +88,39 @@
android:name=".recievers.DSOAirplaneModeReceiver"
android:enabled="true">
<intent-filter>
<action android:name="android.media.action.DISPLAY_NOTIFICATION" />
<action android:name="android.intent.action.AIRPLANE_MODE" />
</intent-filter>
</receiver>
<receiver android:name=".recievers.DSOChangedBroadcastReceiver">
<intent-filter>
<action android:name="android.media.action.DISPLAY_NOTIFICATION" />
<action android:name="android.bluetooth.adapter.action.STATE_CHANGED" />
<action android:name="android.bluetooth.adapter.action.BATTERY_CHANGED" />
</intent-filter>
</receiver>
<receiver android:name=".recievers.DSOStorageReceiver">
<intent-filter>
<action android:name="android.media.action.DISPLAY_NOTIFICATION" />
<action android:name="android.intent.action.DEVICE_STORAGE_LOW" />
</intent-filter>
</receiver>
<receiver android:name=".recievers.DSONetworkStateReceiver">
<intent-filter>
<action android:name="android.media.action.DISPLAY_NOTIFICATION" />
<action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
<action android:name="android.net.wifi.WIFI_STATE_CHANGED" />
</intent-filter>
</receiver>
<receiver android:name=".recievers.DSOBatteryReceiver">
<intent-filter>
<action android:name="android.media.action.DISPLAY_NOTIFICATION" />
<action android:name="android.intent.action.ACTION_BATTERY_LOW" />
</intent-filter>
</receiver>
<receiver android:name=".recievers.DSOLocationReceiver">
<intent-filter>
<action android:name="android.media.action.DISPLAY_NOTIFICATION" />
<action android:name="android.location.PROVIDERS_CHANGED" />
</intent-filter>
</receiver>
@ -148,5 +154,4 @@
android:name=".services.DataBootstrapService"
android:exported="false" />
</application>
</manifest>

Просмотреть файл

@ -35,16 +35,17 @@ public class App extends Application {
// Prepare intent which is triggered if the
// notification is selected
Intent intent = new Intent(getContext(), TutorialSlideActivity.class);
// intent.putExtra("title", topic.getName());
intent.putExtra("topic", tag);
PendingIntent pIntent = PendingIntent.getActivity(getContext(), (int) System.currentTimeMillis(), intent, 0);
// Build notification
// Actions are just fake
Notification notification = new NotificationCompat.Builder(getContext())
.setContentTitle(msg)
.setContentText("Jisort").setSmallIcon(R.drawable.ic_launcher)
.setContentTitle(getContext().getString(R.string.app_name))
.setStyle(new NotificationCompat.BigTextStyle().bigText(msg))
// .setSmallIcon(R.drawable.ic_launcher)
.setContentIntent(pIntent)
.setAutoCancel(true)
.addAction(0, "Lear More", pIntent).build();
NotificationManager notificationManager = (NotificationManager) getContext().getSystemService(NOTIFICATION_SERVICE);
// hide the notification after its selected