android-activity

Activity keeps restarting when orientation changes

被刻印的时光 ゝ 提交于 2020-01-13 05:16:50
问题 how do you keep the activity from restarting when the screen rotates or when then user slides the keyboard on the phone? Is this possible? Is there a work around or something? All relevant answers are appreciated. 回答1: You can do this by declaring a specific attribute in your activity element in your manifest.xml . The element in question is called android:configChanges , and you need to register the string value of orientation . <activity android:name=".MyActivity" android:configChanges=

Activity excludeFromRecents not working on Android 5.0

人走茶凉 提交于 2020-01-12 18:50:27
问题 I'm trying to finish an activity and not have it on the recents. The following code seems to work on KitKat but not on lolipop, as the activity always shows on the recents. intentInvite = new Intent( context, OnInviteActivity.class ); intentInvite.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); intentInvite.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intentInvite = createInviteIntent( intentCloud, intentInvite ); context.startActivity( intentInvite ); AndroidManifest.xml <activity android:name="

Activity excludeFromRecents not working on Android 5.0

懵懂的女人 提交于 2020-01-12 18:46:45
问题 I'm trying to finish an activity and not have it on the recents. The following code seems to work on KitKat but not on lolipop, as the activity always shows on the recents. intentInvite = new Intent( context, OnInviteActivity.class ); intentInvite.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); intentInvite.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intentInvite = createInviteIntent( intentCloud, intentInvite ); context.startActivity( intentInvite ); AndroidManifest.xml <activity android:name="

Activity excludeFromRecents not working on Android 5.0

核能气质少年 提交于 2020-01-12 18:46:30
问题 I'm trying to finish an activity and not have it on the recents. The following code seems to work on KitKat but not on lolipop, as the activity always shows on the recents. intentInvite = new Intent( context, OnInviteActivity.class ); intentInvite.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); intentInvite.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intentInvite = createInviteIntent( intentCloud, intentInvite ); context.startActivity( intentInvite ); AndroidManifest.xml <activity android:name="

What is the usage of onCreate method second implementation in Android Activities?

折月煮酒 提交于 2020-01-12 18:24:04
问题 I have alway used onCreate method inside my Activity lifecycle to start or restore from a saved state, but recently found that there is another onCreate method which contains a PersistableBundle : @Override public void onCreate(Bundle savedInstanceState, PersistableBundle persistentState) { super.onCreate(savedInstanceState, persistentState); } I only found that it has been added since Android 21. Could anyone please give a complete information about this method, when it calls and the usage?

What is the usage of onCreate method second implementation in Android Activities?

半世苍凉 提交于 2020-01-12 18:21:46
问题 I have alway used onCreate method inside my Activity lifecycle to start or restore from a saved state, but recently found that there is another onCreate method which contains a PersistableBundle : @Override public void onCreate(Bundle savedInstanceState, PersistableBundle persistentState) { super.onCreate(savedInstanceState, persistentState); } I only found that it has been added since Android 21. Could anyone please give a complete information about this method, when it calls and the usage?

What is the usage of onCreate method second implementation in Android Activities?

巧了我就是萌 提交于 2020-01-12 18:20:52
问题 I have alway used onCreate method inside my Activity lifecycle to start or restore from a saved state, but recently found that there is another onCreate method which contains a PersistableBundle : @Override public void onCreate(Bundle savedInstanceState, PersistableBundle persistentState) { super.onCreate(savedInstanceState, persistentState); } I only found that it has been added since Android 21. Could anyone please give a complete information about this method, when it calls and the usage?

Activity Idle Timeout for ActivityRecord

拥有回忆 提交于 2020-01-12 14:29:30
问题 So I have a strange problem, and I'm not entirely sure what all information I should provide, but I'll do my best -- just let me know if I need to add more info. I'm having an issue that when I finish my Activity and return to the previous Activity (or launch it with a new Intent -- the problem seems to be centered on finishing the Activity ) the UI performance drops drastically for about six or seven seconds, then returns to normal. From LogCat , this warning appears consistently: 07-11 22

Clear activity stack in android

旧城冷巷雨未停 提交于 2020-01-12 11:51:11
问题 I have a LoginActivity as my launcher screen. And SettingsActivity as my fifth screen . I have a logout button in settings screen. On clcik of this button, how can i go to Screen-1 (i.e LoginActivity) by clearing all remaining activities (i.e 2nd, 3rd, 4th) from activity stack? Note : i have finished LoginActivity but not remaining activities. Thanks in advance 回答1: Simple, set an onclick on your logout button and then add this to your intent: Intent newIntent = new Intent(this, login.class);

Android Double Tap

旧巷老猫 提交于 2020-01-12 05:38:12
问题 How do I use double tap events in an activity? The double tap event or long click method working (though the method is getting overriden) I've just put in a toast message in each of these methods and yet no result! Can you help? 回答1: The easiest way to do a double-tap is to detect it with a GestureDetector. The "trick" is to be sure you delegate the Activity's onTouchEvent to the GestureDetector's onTouchEvent: import android.app.Activity; import android.os.Bundle; import android.view