This Question have 3 answers right now.

Android app killed, push notification click starts main activity first before forwarding activity

Question!

The scenario is as follows:

  • App is started and MainActivity is visible to the user
  • App is put into the background
  • System kills app after a while or activity is destroyed(by turning on the option 'Don't keep activities' in develop options)
  • Push notification is received and is set to forward to a ForwardingActivity
  • On clicking push notification, instead of directly going to ForwardingActivity, first MainActivity is created and then the ForwardingActivity

Some of the code is as follows:

Intent intent = new Intent(Intent.ACTION_VIEW);
intent.addCategory(Intent.CATEGORY_BROWSABLE);
intent.setData(data);
intent.setClassName("packagename", "com.example.ForwardingActivity");

NotificationCompat.Builder builder =
                new NotificationCompat.Builder(context)
                        .setSmallIcon(R.drawable.icon)
                        .setContentTitle("Title")
                        .setContentText("PN text")
                        .setAutoCancel(true)
                        .setDefaults(Notification.DEFAULT_SOUND)
                        .setContentIntent(
PendingIntent.getActivity(context, requestCode, intent, PendingIntent.FLAG_UPDATE_CURRENT));

((android.app.NotificationManager) context.getSystemService(Context
                        .NOTIFICATION_SERVICE)).notify(notificationId, builder.build());

Has anyone faced this before? Even though I'm clearly setting the activity on the intent for the push notification, it is not opened directly.



Answers

You may want to try this Intent constructor to redirect directly to your Activity instead of using setClassName:

https://developer.android.com/reference/android/content/Intent.html#Intent(android.content.Context, java.lang.Class)

Intent intent = new Intent(this, ForwardingActivity.class);
By : nicobatu


I think you need to take a step back and think about how to properly handle the data and fit the model.

Your final modeling data set shouldn't have any missing values, let alone so many missing values that features are 100% missing in CV folds (!).

Instead, do a bit of data cleaning and feature engineering:

  • you can add NA as a factor level to factor variables
  • you can impute missing values in most other situations
  • if a feature has high missingness, then you probably need to exclude it, or
  • if it's not missing at random and there many be some information you can learn by the fact that it was missing / present, you might create one or a few indicator variables indicating if original feature was missing and/or if it contained a certain level of interest.

If you don't want to impute the missing data then you should use the other strategies mentioned. The missing node is not the same as encoding an NA level. The missing node just means that the tree will give the same prediction as prior to the split where data was missing (see R gbm handling of missing values). You should never build a model on a feature with high missingness and it would not be a good practice at all to build a model on data with any missing values. Those should be cleaned when you prepare the data set.

Having said that, you can still impute MNAR data. There are a large number of strategies, going back to Heckman's and Rubin's work in the 70's. A lot of people use mice() and the drawn indicator method.

This may help: http://stefvanbuuren.nl/mi/docs/mnar.pdf

By : Hack-R


There is a way if the first element is the only one to start with that character:

$ a=(asd fgh ijk)
$ echo "${a[@]^[!${a:0:1}]}"
asd Fgh Ijk

This extracts the very first character of the first element, then excludes that character from being uppercased; [!${a:0:1}] expands to [!a], which matches only f and i as the first characters of their elements.

It fails if multiple elements start with the same character, though:

$ a=(asd agh ijk)
$ echo "${a[@]^[!${a:0:1}]}"
asd agh Ijk


Video about Android app killed, push notification click starts main activity first before forwarding activity