Starting activity doesn't bring application to foreground - android

I've got some strange problem with bringing the application to foreground. As it's said in Android documentation using startActivity(myIntent) should bring application from background and it worked until upgrade Android on HTC Desire HD to version 2.3.5. At this version this method doesn't work at all. Application is running in the background even if I add singleInstance flag
Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT.
This is the code snippet where I create the intent and launch activity
Intent intent = new Intent();
intent.setClassName(self.ctx, "com.app.WakeUp");
ctx.startActivity(intent);
The ctx variable is a context passed to the object from Activity instance and com.app.WakeUp is a name of Activity to start.
Some ideas what is going on?

I almost forgot about this question.
The cause of the problem with waking up intent probably is a bug in HTC Desire HD with Android version 2.3.5 (unfortunatelly have no build number). Simple workaround (but not so simple to discover) is for example remote service which can bring the intent to the front.

Related

Running game on separate thread does not stop the whole application from being closed - Unity on Android Studio

More or less the title. I call Application.quit() in Unity, and then in the onUnityPlayerQuitted method in my Android Studio app, I call this code
Intent intent = new Intent(this, Exit.class);
startActivity(intent);
However, this just closes the entire app. I've already got these statements in my androidmanifest.xml
android:launchMode="singleTask"
android:process=":UnityPlayerActivity"
so I can't quite figure out why my app closes instead of going to the Exit activity as I called for it to.
Solved this by changing Application.quit to Application.Unload in Unity, and then having the activities run on different processes using the aforementioned xml tags.

MIUI 11 preventing Activities (of other apps) being launched from foreground service?

In some recent MIUI 11 update, it seems no longer possible to launch an Activity (at least, of another app) from a System Alert Window (SAW) running in a Foreground Service. I can confirm on my MIUI 11.0.5 device (not sure about earlier versions of MIUI 11) and from reports in the wild. This was all working fine a couple of months ago.
I've tested using (with and without the flag):
Intent intent = viewContext.getPackageManager().getLaunchIntentForPackage(otherPackageName);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); // doesn't make a difference
viewContext.startActivity(intent)
called from a OnClickListener on the main View of the SAW.
Logcat shows that the system is getting the intent:
I/Timeline: Timeline: Activity_launch_request time:6329289 intent:Intent...
But nothing actually happens. I noticed calls to a ContentProvider on the other app, work as expected. I even tried starting the activity from within that ContentProvider, but that also did not work.
Perhaps, more generally, the issue is starting Activities (of other apps) from non-Activity Contexts.
Note: although it seems like the same issue as here, the accepted workaround does not apply in this case. Both apps have "Display pop-up windows while running in the background" permission enabled.
Any ideas?

Activity doesn't receive Intent triggered from shortcut when app is running

On some versions of Android, an Activity in my app is not always receiving a shortcut triggered Intent.
The app creates a shortcut with an intent intended for a specific Activity (SomeActivity) in the app
Intent shortcutIntent = new Intent(this, SomeActivity.class);
Intent i = new Intent();
i.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
i.putExtra(Intent.EXTRA_SHORTCUT_NAME, 'shortcut name');
i.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE,Intent.ShortcutIconResource.fromContext(this, R.drawable.icon));
i.setAction("com.android.launcher.action.INSTALL_SHORTCUT"); sendBroadcast(i);
The shortcut is installed as expected.
For a Nexus 5 (4.4.4) and Samsung S5 (4.4.2) and an old Samsung (2.3.6) everything works as expected, namely SomeActivity's onCreate function is called when the shortcut is clicked.
But for other devices e.g. Sony Xperia (4.3) it works as expected if you have previously exited from the app, but if the app is in the background (having previously tasked away from the app by pressing the Home button) then when the shortcut is pressed neither of SomeActivity's onCreate or onNewIntent are called.
I managed to fix the problem by either setting a flag on the intent:
scIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
or setting the launchMode in the manifest to singleTask.
In both these cases onCreate of SomeActivity is always called irrespective of the state of the app (not running or in background).
But launchModes of standard or singleTop don't work (if the app is in background), the app merely comes to the foreground but SomeActivity's onCreate or onNewIntent are not called. I don't understand why they aren't.
For the record I originally had no launchMode defined (so defaults to standard) and everything behaved correctly. I believe the problem only surfaced when I updated SDK build tools to:
Android SDK Tools 23.0.2
Android SDK Platform Tools 20
Android Build Tools 20

Cannot Start Activity After EXTRA_STATE_OFFHOOK(Outgoing call) on 4.0.3

I am quite new in android environment.
This problem occur on android 4.0.3 but it is working on android 2.2. I just could start activity after outgoing call. I just want to call back my activity to foreground while making phone call. but it is working on android 2.2 but it is not working on 4.0.3.
Here is my code. This code working on both version on incoming state.
But it is not working on 4.0.3 on outgoing intent. I call this intent from BroadcastReceiver. Please note that i do not want to end phone calling activity while my activity in foreground state. I set launch mode to "singleInstance" on Mainfest.xml.
Toast.makeText(context, "Should Start Activity", Toast.LENGTH_LONG).show();
Intent callsensorintent = new Intent();
callsensorintent.setFlags(
Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT
|Intent.FLAG_ACTIVITY_REORDER_TO_FRONT
|Intent.FLAG_ACTIVITY_NEW_TASK
);
callsensorintent.setClassName(context,"com.example.test.sg.SensorUdp");
context.startActivity(callsensorintent);
Thanks
The call screen on ICS has a higher priority than before, so it will show on top over everything else when it's in the foreground. Now it even has a higher priority than the notification menu/curtain.
You can use a higher window priority for your application, e.g. WindowManager.LayoutParams.TYPE_SYSTEM_ALERT.

Android - Access class in phone.apk

Hi guys this is just my first post,
is it possible to access an activity which is in Phone.apk in a non-rooted phone?
I've tried something like this
Intent i = new Intent(Intent.ACTION_MAIN);
i.setClassName("com.android.phone", "com.android.phone.PhoneApp");
startActivity(i);
but my app always stops unexpectedly.
There is no activity named com.android.phone.PhoneApp in the Android firmware, let alone in the Android SDK.
Moreover, you should not be attempting to start activities in the com.android package, as they are not part of the Android SDK and may or may not exist on any given device or Android version.

Categories

Resources