android-homebutton

How to trigger a function when a user goes back to a background app?

筅森魡賤 提交于 2019-12-11 04:17:33
问题 For example, an user opens an app, presses the home button, and then comes back to the app again. Is there any way to trigger certain functions when the user navigates back to the app? Such as auto load a view object when the user is back to the app. This question is for both Android & iOS. 回答1: Use the following to your likings in the projects's AppDelegate.m file (iOS only) - (void)applicationWillResignActive:(UIApplication *)application { // Sent when the application is about to move from

onPause not fired when home button is pressed

给你一囗甜甜゛ 提交于 2019-12-10 18:07:48
问题 I have an Android AppCompatActivity that fails to fire onPause event when the Home button is pressed. According to the Android documentation: The system calls this method as the first indication that the user is leaving your activity (though it does not always mean the activity is being destroyed); However, whenever I am in the AppCompatActivity, onPause does not fire when Home button is pressed. Otherwise it fires as expected for back button or normal close of the AppCompatActivity. I have

Which method is run when Home button pressed?

﹥>﹥吖頭↗ 提交于 2019-12-10 13:22:38
问题 I have a Home replacement Activity from within which you can launch a number of apps. When you tap the Home button, you are returned to my Home replacement Activity. As I understand, tapping the Home button creates an intent to launch the Home screen and then starts that intent (I might be wrong, please correct me if I am!). If this is the case, I'd expect the onCreate() method to be run whenever the Home screen is created. On the other hand, when you launch another activity, the Home screen

Started activity from home key screen

陌路散爱 提交于 2019-12-09 18:49:39
问题 I have a background Service which starts an activity, Intent i = new Intent(this, MyActivity.class); i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(i); After destroying this Activity and restart it over the "long press home key menu", this Activity starts again. But I want to start the main activity instead. How could I realise this? 回答1: Could you explain in more detail? If I understand your problem try setting the FLAG_ACTIVITY_NO_HISTORY. Alternatively a manual solution would be

Go to home screen from Android Activity

自闭症网瘾萝莉.ら 提交于 2019-12-08 00:37:12
问题 I'm making an application in android and I want to implement a button such that whenever it is pressed, I just reach back to my home screen. I know that we have the hardware key and soft keys( when there are no hardware keys) which implements this, but I want to add this functionality for this application. Does anybody has any idea how to do it? Thank you 回答1: Try this Intent intent = new Intent(Intent.ACTION_MAIN); intent.addCategory(Intent.CATEGORY_HOME); intent.setFlags(Intent.FLAG

setHomeButtonEnabled on PreferenceActivity and nested preference

给你一囗甜甜゛ 提交于 2019-12-06 00:30:35
问题 I have preference screen extended PreferenceActivity . For targeting OS 4.0.3, I wanted to add < icon on action bar so I did this in onCreate() . ActionBar actionBar = getActionBar(); actionBar.setHomeButtonEnabled(true); actionBar.setDisplayHomeAsUpEnabled(true); It worked. < was added to left of app icon. But when I tap the item which goes into the next level (more detail screen), the < won't be displayed. Returning to the top level, the < appears again. I have never thought about a

Android Toolbar with both home and back button

与世无争的帅哥 提交于 2019-12-05 19:26:55
问题 Is it possible to display both home icon and back icon in the toolbar? 1) Is it possible change the order of display of back button icon and home icon. Currently it displays the arrow button first and then the logo (home button) 2) Second requirement is to clear the activity stack on clicking the home icon and going back to previous screen in case of back button. I have the following code which will display a arrow back key and home icon which is set as logo. Is it possible to handle click

adb shell dumpsys activity activities shows two instances of single task in separate stack

醉酒当歌 提交于 2019-12-05 16:39:54
I have a main activity having intent with CATEGORY_HOME to behave like a launcher. It also has CATEGORY_LAUNCHER so that user can access from App Drawer. Here is the main activity: public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } @Override protected void onResume() { super.onResume(); } @Override protected void onDestroy() { super.onDestroy(); } } I have another activity containing a button to call the MainActivity with HOME intent. It is another

Started activity from home key screen

大兔子大兔子 提交于 2019-12-04 12:46:25
I have a background Service which starts an activity, Intent i = new Intent(this, MyActivity.class); i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(i); After destroying this Activity and restart it over the "long press home key menu", this Activity starts again. But I want to start the main activity instead. How could I realise this? Could you explain in more detail? If I understand your problem try setting the FLAG_ACTIVITY_NO_HISTORY. Alternatively a manual solution would be to check the FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY on the intent in MyActivity and launch to the main activity

setHomeButtonEnabled on PreferenceActivity and nested preference

亡梦爱人 提交于 2019-12-04 07:50:59
I have preference screen extended PreferenceActivity . For targeting OS 4.0.3, I wanted to add < icon on action bar so I did this in onCreate() . ActionBar actionBar = getActionBar(); actionBar.setHomeButtonEnabled(true); actionBar.setDisplayHomeAsUpEnabled(true); It worked. < was added to left of app icon. But when I tap the item which goes into the next level (more detail screen), the < won't be displayed. Returning to the top level, the < appears again. I have never thought about a mechanism of nested preference since smart the PreferenceActivity hides it. Now my question is, why won't