android-activity

How to set ContentPage orientation in Xamarin.Forms

若如初见. 提交于 2020-01-01 04:51:05
问题 I'm using Xamarin.Forms to create a cross platform application, all of my ContentPages are situated within the PCL . I'm looking for a way to set and lock the orientation of a single ContentPage to Landscape , preferably without having to create another activity in each of the platform specific projects. Since my ContentPage.Content is set to a ScrollView , I've tried setting the ScrollOrientation to Horizontal , however this did not work. I've also tried using a RelativeLayout , but I can't

Detecting android Activity launches

倾然丶 夕夏残阳落幕 提交于 2020-01-01 04:39:25
问题 I have searched the stackoverflow for this question and found : Android, Detect when other apps are launched and Reliable way to detect application launch from home / desktop? , which kind of answers my question but it's still not enough. What I want to do I want to create a widget/app that shows the user of the device a list of recent apps and a list of most used apps. Problem How can I have accurate data about the apps in order to build a list of most used apps. Base information I am

in Android if OS kills my application, will getIntent() return the Intent with the same extras?

落花浮王杯 提交于 2020-01-01 04:09:07
问题 After my application has been restored, of course. or I have to store everything at onSaveInstanceState()? 回答1: This conversation seems to answer it: http://groups.google.com/group/android-developers/browse_thread/thread/f47af26b696af2e2. Look for the post starting with "Yes and no" and the few before it. The answer is in the positive: yes, after restart of an Activity shut down by the OS, getIntent() will return an Intent with the same extras as the original . Nevertheless, if some Android

Why would I ever want `setRetainInstance(false)`? - Or - The correct way to handle device rotation

瘦欲@ 提交于 2020-01-01 04:08:13
问题 Please correct me if I'm wrong on any of this. This is a kind of clarifying question since I haven't seen it explicitly written anywhere. In Android 4, you can call setRetainInstance(true) on a Fragment so that on configuration changes (which basically means device rotation), the Fragment java object isn't destroyed and a new instance of it isn't created. That is, the instance is retained. This is much more sane and less infuriating than in Android 1-3 since you don't have to deal with

Start Activity from preferences.xml and get the result in onActivityResult

拜拜、爱过 提交于 2020-01-01 04:04:08
问题 It's a complement to this question. I can launch the Activity but I also need to be able to get the result. How do I do it? I tried overriding onActivityResult on my PreferencesActivity to no avail. Am I missing some extra properties in the preferences.xml? 回答1: The cleanest solution that I know of is to listen to the click on the preference and launch the intent explicitly. This way onActivityResult will be called as usual. Assuming that your intent-preference is defined in XML you can

Android: activity transition/animation in ActivityGroup

隐身守侯 提交于 2020-01-01 04:01:07
问题 I use ActivityGroup to manage activities, I want to add animation when change activity, the code I used to change to next activity is: Intent intent = new Intent(getParent(), AnotherActivity.class); TabGroupActivity parentActivity = (TabGroupActivity) getParent(); parentActivity.startChildActivity("AnotherActivity", intent); And inside startChildActivity : Window window =getLocalActivityManager().startActivity(Id,intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)); if (window != null) { View

why does android 'revives' crashing apps?

为君一笑 提交于 2020-01-01 03:20:11
问题 if you have an android app that has more than one Activity, and Activity A starts B, so if Activity b crashes the process is killed but is revived by android OS and starts Activity A again instead of just shutting down the app, why ? 回答1: You're complaining that Android will attempt to recover your app's state gracefully after a crash? ;) This is the result of Android's resource management and the Activity lifecycle at work. Keep in mind that a single task can be composed of a number of

Android app start and end event

纵饮孤独 提交于 2020-01-01 02:40:08
问题 I have an app which track user activity on app which include time etc, Now if user has opened the app, It will start an session and till user in this app , his session will continue, He can switch to multiple activity. Now meantime he switches to another app, His session logging should be stopped and written down to file What I tried I created one base activity and On resume event if counter is zero, I start session and increment counter and On stop event , i decrement counter and if counter

Transfer Socket from one Activity to another

二次信任 提交于 2020-01-01 02:33:07
问题 I am trying to transfer Socket attribute from one Activity to another but i can not use Intent.putExtra() method. socket = new Socket("10.0.0.9", port); i = new Intent(getBaseContext(), MainActivity.class); i.putExtra("mysocket", socket); How i can transfer Socket from one Activity to another? 回答1: You can't 'pass a Socket' from one Activity to another, but you do have other options. Option 1 . Create a class with a static reference to your Socket and access it that way. In your first

Android preload a url into WebView while splashscreen is showing

情到浓时终转凉″ 提交于 2020-01-01 00:12:46
问题 I have an app with a splash-screen which after a few seconds opens up the main activity that has a WebView. The problem is that, only then, does the main activity start to load the URL, which sometimes take several seconds. It seems silly for the double wait. However, my attempts to pre-load the WebView have been less then successful. The essence of the issue is that the splash screen and main activity are two different activities and the WebView is resource bound (layout) to the main