oncreate

android what to use instead of onRestart() in a fragment

纵然是瞬间 提交于 2019-12-02 06:13:35
I'm dealing with .setVisibility() of a view , inside my main fragment at app start. So what I want is that the view is invisible on app start (for this i set INVISIBLE inside onCreateView) and to be visible when I come back to my fragment from other activities while the app is open (and for this I tried to use onRestart() to set view VISIBLE but it cannot resolve onRestart method) is onRestart deprecated or? thanks EDIT: for all the answers below suggesting to use an onResume (and whom gave a -1), onResume doesn't work as onRestart at all, cause is being called right after onCreateView.

Want to display AlertDialog in onCreate of Activity - android

风格不统一 提交于 2019-12-01 14:37:32
In my activity, I call a MyDialog (custom dialog) in onCreate() and handle its DismissListener in Activity to find if its cancelled or not. If its cancelled, I finish the activity, else load the activty. During this loading time, I want to show a Alert/Progress dialog to let the user know that its loading, please wait. But am not able to see the dialog. This is how I have coded : public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ld = new AgreeDialog(this); ld.setOnDismissListener(new OnDismissListener() { @Override public void onDismiss(DialogInterface

Can I startService from Application#onCreate()?

こ雲淡風輕ζ 提交于 2019-11-30 11:23:58
I want to start a service when my Application is initialized from whatever component. public class MyApplication extends Application { @Override public void onCreate() { super.onCreate(); startService(new Intent(getApplicationContext(), MyService.class)); } } Is the Service available in the onCreate() state? Will the super.onCreate() initialize all components of an Application registered in the AndroidManifest.xml ? I can run this code in my galaxy s, but I can't make sure it will be run in all devices and platforms, I can't find any documentation about the initialization of an Android APP.

onCreate() called while Activity is stopped (but not destroyed). Only after installation

半腔热情 提交于 2019-11-30 10:17:13
I'm working on an app that targets Api 19, and that is basically a Processing sketch. The problem I'm facing is that the first time my app is run, right after installing it, it works well until the user sends it to the background. Then, if they click on the app icon again, onCreate() is called but the activity is not destroyed or restarted. Some variables change and that produces strange behaviours. This happens ONLY the first time the app is used. After force closing it, this behaviour won't happen ever again (as far as I've tested). And this does not happen when launching the app from

get activityInfo metaData in onCreate method

余生颓废 提交于 2019-11-30 06:59:32
问题 I need to retrieve a value from the AndroidManifest.xml file, stored as a meta data: <meta-data android:value="3" android:name="myInterestingValue" /> In the onCreate method, I call the following method: private Object getMetaData(String name) { try { ActivityInfo ai = getPackageManager().getActivityInfo(this.getComponentName(), PackageManager.GET_META_DATA); Bundle metaData = ai.metaData; if(metaData == null) { debug("metaData is null. Unable to get meta data for " + name); } else { Object

Can I startService from Application#onCreate()?

为君一笑 提交于 2019-11-29 17:02:41
问题 I want to start a service when my Application is initialized from whatever component. public class MyApplication extends Application { @Override public void onCreate() { super.onCreate(); startService(new Intent(getApplicationContext(), MyService.class)); } } Is the Service available in the onCreate() state? Will the super.onCreate() initialize all components of an Application registered in the AndroidManifest.xml ? I can run this code in my galaxy s, but I can't make sure it will be run in

When I return back to my Activity onCreate is raised instead of onActivityResult?

流过昼夜 提交于 2019-11-29 17:01:20
I have an Activity that opens a new Activity for result like this: Intent i = new Intent(ActDocument.this, ActCustomers.class); startActivityForResult(i, ActDocument.DIALOG_CUSTOMER); when I press back in the child Activity and return back to the parent Activity onActivityResult is called in all of devices correctly but I have fount a device that onCreate is called instead of onActivityResult . This device is Samsung Galaxy Tab-P5100 Android 4.0.3. It is strange that I have tested my application on other devices of Samsung Galaxy Tab-P5100 Android 4.0.3 and it was OK but I have problem only in

onCreate() called while Activity is stopped (but not destroyed). Only after installation

核能气质少年 提交于 2019-11-29 15:15:47
问题 I'm working on an app that targets Api 19, and that is basically a Processing sketch. The problem I'm facing is that the first time my app is run, right after installing it, it works well until the user sends it to the background. Then, if they click on the app icon again, onCreate() is called but the activity is not destroyed or restarted. Some variables change and that produces strange behaviours. This happens ONLY the first time the app is used. After force closing it, this behaviour won't

what is the different between onCreate() and onCreateView() lifecycle methods in Fragment?

一曲冷凌霜 提交于 2019-11-29 11:31:12
问题 I don't know when to use onCreate() or onCreateView() . I have used onCreate() and onCreateView() lifecycle methods. I think onCreate() for Activity and onCreateView() for Fragment. But I am not sure. Can I use onCreate() LifeCycle method in Fragment? I hope somebody can help me! 回答1: onCreate is called on initial creation of the fragment. You do your non graphical initializations here. It finishes even before the layout is inflated and the fragment is visible. onCreateView is called to

Where to set all Listeners?

空扰寡人 提交于 2019-11-29 09:27:05
Where to set all Listeners for the user interfaces? Is it good practice to set them in onCreate ? This looks so unstructured and strange. Is there a better place to set them? Ilya Demidov From here: http://developer.android.com/reference/android/app/Activity.html onCreate(Bundle) is where you initialize your activity. Most importantly, here you will usually call setContentView(int) with a layout resource defining your UI, and using findViewById(int) to retrieve the widgets in that UI that you need to interact with programmatically. When you initialize your views, they are ready to be listened.