Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

one possible solution for issue #7 #16

Merged
merged 3 commits into from
May 9, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/android/AppStarter.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ public class AppStarter {
public static final int BYPASS_USERPRESENT_MODIFICATION = -1;

public void run(Context context, Intent intent, int componentState) {
this.run(context, intent, componentState, false);
}

public void run(Context context, Intent intent, int componentState, boolean onAutostart) {
// Enable or Disable UserPresentReceiver (or bypass the modification)
//Log.d("Cordova AppStarter", "UserPresentReceiver component, new state:" + String.valueOf(componentState));
if( componentState != BYPASS_USERPRESENT_MODIFICATION ) {
Expand All @@ -33,6 +36,9 @@ public void run(Context context, Intent intent, int componentState) {
serviceIntent.setClassName(context, packageName + "." + className);
serviceIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
serviceIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
if (onAutostart) {
serviceIntent.putExtra("cordova_autostart", true);
}
context.startActivity(serviceIntent);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/android/BootCompletedReceiver.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ public class BootCompletedReceiver extends BroadcastReceiver {
public void onReceive(Context context, Intent intent) {

AppStarter appStarter = new AppStarter();
appStarter.run(context, intent, PackageManager.COMPONENT_ENABLED_STATE_ENABLED);
appStarter.run(context, intent, PackageManager.COMPONENT_ENABLED_STATE_ENABLED, true);
}
}
}
2 changes: 1 addition & 1 deletion src/android/UserPresentReceiver.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ public class UserPresentReceiver extends BroadcastReceiver {
public void onReceive(Context context, Intent intent) {

AppStarter appStarter = new AppStarter();
appStarter.run(context, intent, PackageManager.COMPONENT_ENABLED_STATE_DISABLED);
appStarter.run(context, intent, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, true);
}
}