• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Can't get notification working

Devy60

Lurker
I'm working on a very simple app on Android Studio and I'm trying to create a notification that's activated on some case in a timer loop.
I'm running the app on 4.4.3 LG G2 D802 phone. the min API is 18 and target is 23.

I followed instructions from multiple sites and this is what I did:

MainActivity:
(mA is the current activity object like 'this')

int mNotificationId = 101;
mBuilder.setContentTitle("tset");
shopsAvail = where.split("|");
String all = shopsAvail.toString();
mBuilder.setContentText("test"+all);
NotificationManager mNotifyMgr = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
Intent resultIntent = new Intent(mA, MainActivity.class);
PendingIntent resultPendingIntent =
PendingIntent.getActivity(
mA,
0,
resultIntent,
PendingIntent.FLAG_UPDATE_CURRENT
);
mBuilder.setContentIntent(resultPendingIntent);
mNotifyMgr.notify(mNotificationId, mBuilder.build());


AndroidManifest:


<activity
android:name="com.whereismypizero.notification.raspzerostocknotifier.MainActivity"
android:label="@String/app_name" >

<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>

</activity>

<activity android:name=".ResultAct"
android:label="Details of notification"
android:parentActivityName=".MainActivity">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".MainActivity"/>
</activity>


There are no errors but it's doing absolutely nothing while I know that the code is running by Log.d.
 
sometimes android blocks app notifications by default
for the first solution check your settings (Notification Manager) or test your app in another phone
Luck
 
Back
Top Bottom