Skip to content

Commit

Permalink
fixed notification not showing correct activity or fragment bug
Browse files Browse the repository at this point in the history
  • Loading branch information
hani-28 committed Jun 17, 2019
1 parent 5592f49 commit 8a157a7
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 18 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ android {
applicationId "com.HMSolutions.thikrallah"
minSdkVersion 21
targetSdkVersion 28
versionCode 101
versionName "5.1"
versionCode 103
versionName "5.3"
}
lintOptions {
disable 'MissingTranslation'
Expand Down
2 changes: 1 addition & 1 deletion app/release/output.json
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":100,"versionName":"5.0.9","enabled":true,"outputFile":"app-release.apk","fullName":"release","baseName":"release"},"path":"app-release.apk","properties":{}}]
[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":103,"versionName":"5.3","enabled":true,"outputFile":"app-release.apk","fullName":"release","baseName":"release"},"path":"app-release.apk","properties":{}}]
Original file line number Diff line number Diff line change
Expand Up @@ -209,11 +209,11 @@ public void run() {
mBuilder.setSound(soundUri,AudioManager.STREAM_NOTIFICATION);

Intent launchAppIntent = new Intent(this, MainActivity.class);

launchAppIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
launchAppIntent.putExtra("FromNotification",true);
launchAppIntent.putExtra("DataType", MainActivity.DATA_TYPE_DAY_THIKR);
PendingIntent launchAppPendingIntent = PendingIntent.getActivity(this,
0, launchAppIntent, PendingIntent.FLAG_ONE_SHOT|PendingIntent.FLAG_UPDATE_CURRENT
1458, launchAppIntent, PendingIntent.FLAG_ONE_SHOT|PendingIntent.FLAG_UPDATE_CURRENT
);

mBuilder.setContentIntent(launchAppPendingIntent);
Expand Down Expand Up @@ -258,11 +258,11 @@ public void run() {
mBuilder.setSound(soundUri,AudioManager.STREAM_NOTIFICATION);

Intent launchAppIntent = new Intent(this, MainActivity.class);

launchAppIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
launchAppIntent.putExtra("FromNotification",true);
launchAppIntent.putExtra("DataType", MainActivity.DATA_TYPE_NIGHT_THIKR);
PendingIntent launchAppPendingIntent = PendingIntent.getActivity(this,
0, launchAppIntent, PendingIntent.FLAG_ONE_SHOT|PendingIntent.FLAG_UPDATE_CURRENT
2354, launchAppIntent, PendingIntent.FLAG_ONE_SHOT|PendingIntent.FLAG_UPDATE_CURRENT
);

mBuilder.setContentIntent(launchAppPendingIntent);
Expand Down Expand Up @@ -309,12 +309,13 @@ public void run() {
Uri soundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
mBuilder.setSound(soundUri,AudioManager.STREAM_NOTIFICATION);
Intent launchAppIntent = new Intent(this, MainActivity.class);
launchAppIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
launchAppIntent.putExtra("page", 562);
launchAppIntent.putExtra("FromNotification",true);
launchAppIntent.putExtra("DataType", MainActivity.DATA_TYPE_QURAN);

PendingIntent launchAppPendingIntent = PendingIntent.getActivity(this,
0, launchAppIntent, PendingIntent.FLAG_ONE_SHOT|PendingIntent.FLAG_UPDATE_CURRENT
9854, launchAppIntent, PendingIntent.FLAG_ONE_SHOT|PendingIntent.FLAG_UPDATE_CURRENT
);

mBuilder.setContentIntent(launchAppPendingIntent);
Expand Down Expand Up @@ -400,10 +401,11 @@ public void run() {
Uri soundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
mBuilder.setSound(soundUri,AudioManager.STREAM_NOTIFICATION);
Intent launchAppIntent = new Intent(this, PagerActivity.class);
launchAppIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
launchAppIntent.putExtra("page", 562);

PendingIntent launchAppPendingIntent = PendingIntent.getActivity(this,
0, launchAppIntent, PendingIntent.FLAG_ONE_SHOT|PendingIntent.FLAG_UPDATE_CURRENT
9577, launchAppIntent, PendingIntent.FLAG_ONE_SHOT|PendingIntent.FLAG_UPDATE_CURRENT
);

mBuilder.setContentIntent(launchAppPendingIntent);
Expand Down Expand Up @@ -452,12 +454,13 @@ public void run() {
Uri soundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
mBuilder.setSound(soundUri,AudioManager.STREAM_NOTIFICATION);
Intent launchAppIntent = new Intent(this, MainActivity.class);
launchAppIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
launchAppIntent.putExtra("page", 293);
launchAppIntent.putExtra("FromNotification",true);
launchAppIntent.putExtra("DataType", MainActivity.DATA_TYPE_QURAN);

PendingIntent launchAppPendingIntent = PendingIntent.getActivity(this,
0, launchAppIntent, PendingIntent.FLAG_ONE_SHOT|PendingIntent.FLAG_UPDATE_CURRENT
98521, launchAppIntent, PendingIntent.FLAG_ONE_SHOT|PendingIntent.FLAG_UPDATE_CURRENT
);

mBuilder.setContentIntent(launchAppPendingIntent);
Expand Down Expand Up @@ -541,10 +544,11 @@ public void run() {
Uri soundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
mBuilder.setSound(soundUri,AudioManager.STREAM_NOTIFICATION);
Intent launchAppIntent = new Intent(this, PagerActivity.class);
launchAppIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
launchAppIntent.putExtra("page", 562);

PendingIntent launchAppPendingIntent = PendingIntent.getActivity(this,
0, launchAppIntent, PendingIntent.FLAG_ONE_SHOT|PendingIntent.FLAG_UPDATE_CURRENT
8588, launchAppIntent, PendingIntent.FLAG_ONE_SHOT|PendingIntent.FLAG_UPDATE_CURRENT
);

mBuilder.setContentIntent(launchAppPendingIntent);
Expand Down Expand Up @@ -694,8 +698,9 @@ private void showForegroundNotificationan(int ID){
mBuilder=setVisibilityPublic(mBuilder);
mBuilder.setSound(null);
Intent launchAppIntent = new Intent(this, MainActivity.class);
launchAppIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
PendingIntent launchAppPendingIntent = PendingIntent.getActivity(this,
0, launchAppIntent, PendingIntent.FLAG_ONE_SHOT|PendingIntent.FLAG_UPDATE_CURRENT
45, launchAppIntent, PendingIntent.FLAG_ONE_SHOT|PendingIntent.FLAG_UPDATE_CURRENT
);
mBuilder.setContentIntent(launchAppPendingIntent);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,16 +262,16 @@ public void onCallStateChanged(int state, String incomingNumber) {
private void initNotification() {

Intent resultIntent = new Intent(this, MainActivity.class);
if (getThikrType().equals(MainActivity.DATA_TYPE_GENERAL_THIKR)) {
//if (getThikrType().equals(MainActivity.DATA_TYPE_GENERAL_THIKR)) {
resultIntent.putExtra("FromNotification", true);
resultIntent.putExtra("DataType", this.getThikrType());

}
//}


resultIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
PendingIntent launchAppPendingIntent = PendingIntent.getActivity(this,
0, resultIntent, PendingIntent.FLAG_ONE_SHOT|PendingIntent.FLAG_UPDATE_CURRENT
0, resultIntent, PendingIntent.FLAG_UPDATE_CURRENT
);

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
Expand Down Expand Up @@ -353,7 +353,7 @@ private void addAction(NotificationCompat.Builder builder, String label, int ico
Intent intent = new Intent(label).setClass(this.getApplicationContext(), ThikrMediaBroadcastReciever.class);
intent.putExtras(callingintent.getExtras());
PendingIntent RecieverPendingIntent = PendingIntent.getBroadcast(this, 1,
intent, PendingIntent.FLAG_ONE_SHOT|PendingIntent.FLAG_UPDATE_CURRENT);
intent, PendingIntent.FLAG_UPDATE_CURRENT);


// Log.d(TAG, RecieverPendingIntent.getTargetPackage());
Expand All @@ -370,14 +370,15 @@ private void addAction(NotificationCompat.Builder builder, String label, int ico

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
Crashlytics.log("ThikrMediaPlayerService onStartCommand");
this.setThikrType(intent.getExtras().getString("com.HMSolutions.thikrallah.datatype", null));
Crashlytics.log("ThikrMediaPlayerService onStartCommand. ThikrType is "+getThikrType());
Log.d(TAG,"ThikrMediaPlayerService onStartCommand");
callingintent = intent;
Bundle data = intent.getExtras();
mcontext = this.getApplicationContext();
this.isUserAction = data.getBoolean("isUserAction", false);
int action = data.getInt("ACTION", -1);
this.setThikrType(intent.getExtras().getString("com.HMSolutions.thikrallah.datatype", null));


Log.d(TAG, "action " + action);

Expand Down

0 comments on commit 8a157a7

Please sign in to comment.