|
FOROS PROFESIONALES WINDEV, WEBDEV y WINDEV Mobile |
| | | | | |
| bring up my application WDM 18 |
| Iniciado por guest, 28,jun. 2015 00:48 - 2 respuestas |
| |
| | | |
|
| |
| Publicado el 28,junio 2015 - 00:48 |
I have an application where a persistent thread shot and generates a notification when a new event arrives. All this does it very well.
I need that shot when the notification prompted the application is in the background and to the foreground so that the user sees.
I have this procedure but has errors
public void startNewActivity(Context context, String packageName) { Intent intent = context.getPackageManager().getLaunchIntentForPackage(packageName); if (intent != null) { // We found the activity now start the activity intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(intent); } else { // Bring user to the market or let them choose an app? intent = new Intent(Intent.ACTION_VIEW); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.setData(Uri.parse("market://details?id=" + packageName)); context.startActivity(intent); } }
Thanks for your help Tobias |
| |
| |
| | | |
|
| | |
| |
| Publicado el 29,junio 2015 - 17:07 |
Tobias,
I'm not sure it is perfect, but this does work correctly for my Android application
public static void JBringAppToFront() { try { // Retrieve the current activity Activity tmpActivity = getCurrentActivity(); // Retrieve the current Context Context tmpContext = getApplicationContext(); // Get Class name String packageName = tmpContext.getPackageName(); Intent launchIntent = tmpContext.getPackageManager().getLaunchIntentForPackage(packageName); String className = launchIntent.getComponent().getClassName(); // Create intent / activity Intent myIntent = new Intent(); myIntent.setClassName(tmpContext,className); myIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); // You need this if starting the activity from a service myIntent.setAction(Intent.ACTION_MAIN); myIntent.addCategory(Intent.CATEGORY_LAUNCHER); // Start the activity tmpContext.startActivity(myIntent); } catch(Exception e) { e.printStackTrace(); } } If you want to show your application on top of the lockscreen so the user can directly see what is happening you can set some extra flags in the initialization code of that window.
public static boolean SetExtraWindowFlags() { // Set Some Extra Window Flags Activity tmpActivity = getCurrentActivity(); tmpActivity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON); return true; } And when you call this code it will wake your device, turn the screen on and show your application fullscreen
public static boolean JWakeDevice(boolean bWakeup) { // Wake or rest the device try { if (bWakeup) { //callWLProcedure("ShowMessage","Wake UP"); // Awake the Device Activity tmpActivity = getCurrentActivity(); tmpActivity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED | WindowManager.LayoutParams.FLAG_FULLSCREEN); } else { // Reset stuff //callWLProcedure("ShowMessage","Rest"); Activity tmpActivity = getCurrentActivity(); tmpActivity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED | WindowManager.LayoutParams.FLAG_FULLSCREEN); } } catch(Exception e) { e.printStackTrace(); return false; } return true; } Hope this code helps !
If you apply any improvements, please let me know what you have done to make these functions any better ! 
You will have to include the correct import statements before it will compile.
Have a nice day Danny |
| |
| |
| | | |
|
| | |
| |
| Publicado el 06,julio 2015 - 02:06 |
Danny thank you very much
It is just what was wanted, everything worked perfectly.
Thanks Danny
Tobias :spos: |
| |
| |
| | | |
|
| | | | |
| | |
| | |
| |
|
|
|