1. Download our Official Android App: Forums for Android!

Apps Can't get notification working

Discussion in 'Android Development' started by Devy60, Apr 26, 2016.

  1. Devy60

    Devy60 Lurker
    Thread Starter
    Rank:
    None
    Points:
    5
    Posts:
    1
    Joined:
    Apr 26, 2016

    Apr 26, 2016
    1
    0
    5
    Male
    Israel
    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.
     

    Advertisement

  2. mnakhaepoor

    mnakhaepoor Lurker
    Rank:
    None
    Points:
    5
    Posts:
    4
    Joined:
    Jan 11, 2016

    Jan 11, 2016
    4
    0
    5
    Male
    sometimes android blocks app notifications by default
    for the first solution check your settings (Notification Manager) or test your app in another phone
    Luck
     

Share This Page

Loading...