lifecycle

Android: Create service that runs when application stops

*爱你&永不变心* 提交于 2019-11-27 21:43:05
How do you create a Service that keeps on running when your application is stopped? I am creating the service in a separate process in the manifest file: <service android:name="com.example.myservice" android:process=":remoteservice" /> I am also returning START_STICKY in the Service's onStartCommand: @Override public in onStartCommand(Intent intent, int flags, int startId){ return Service.START_STICKY; } I wouldn't use the android:process attribute - this actually runs your service in a separate process and makes it hard to do things like share preferences. You won't have to worry about your

Call method in EJB on JBoss startup [duplicate]

爱⌒轻易说出口 提交于 2019-11-27 21:02:10
问题 This question already has answers here : Eager / auto loading of EJB / load EJB on startup (on JBoss) (2 answers) Closed 3 years ago . I'm looking for an entry point in an EJB deployed on JBoss. Servlets have the load-on-startup tag to use in its web.xml . I'm searching for similar init() functionality for an EJB. 回答1: That didn't exist for EJB until 3.1. With EJB 3.1 you can use a singleton bean to simulate that: From Application Startup / Shutdown Callbacks: @Startup @Singleton public class

Android Application class method onCreate being called multiple times

筅森魡賤 提交于 2019-11-27 20:14:47
i've overloaded the Application class in my android app and i'm using the ACRA report system. My app looks like ( real source code here ) : public class MyApplication extends Application { @Override public void onCreate() { ACRA.init( this ); /* * Initialize my singletons etc * ... * ... */ super.onCreate(); } } And as far as i know, the Application object should be created only once, so the onCreate method should be called only once. The problem is, that in my crash reports ( from ACRA ) i have this: java.lang.RuntimeException: Unable to create service it.evilsocket.myapp.net.N ... java.lang

How to distinguish between orientation change and leaving application android

。_饼干妹妹 提交于 2019-11-27 19:15:16
I understand that when the orientation of the screen changes, the current activities onDestroy() is called followed by the onCreate() to effectively recreate the activity. I need to know how to programmatically tell if the application is being exited or if just the orientation is being changed. One method is for the previous activity to notify me when its onResume() method is being called, this will let me know that the user has pressed the back button and the orientation hasn't been changed. P.S. I'm looking for a solution more elegant than listening for a back hardware button click. Here was

How to check if my activity is the current activity running in the screen

扶醉桌前 提交于 2019-11-27 19:05:48
I used Toast to make notification, but it seems it will appear even its activity is not in the current screen and some other activity has been started. I want to check this situation, when the activity is not the current one, I'd not send the Toast notification. But how to do ? Andy Zhang When your Activity comes to the foreground, its onResume() method will be invoked. When another Activity comes in front of your Activity, its onPause() method will be invoked. So all you need to do is implement a boolean indicating if your Activity is in the foreground: private boolean isInFront; @Override

Difference between UIInput#getValue() and getLocalValue() during validation

十年热恋 提交于 2019-11-27 18:45:16
问题 I would like to have an illustrative explanation about the difference between getValue() and getLocalValue() methods of UIInput components in the aspect of performing multiple field validation: jsf validate two fields in one time. What is the difference in usage of this methods if the fields are already validated? The ValueHolder API documentation is not very helpful in answering this. 回答1: If the UIInput component has been validated beforehand and is marked invalid (i.e. isValid() method

JSF skip Required-Validation without immediate=true

£可爱£侵袭症+ 提交于 2019-11-27 17:36:23
I have multiple forms, where I have mandatory fields and optional fields. To submit such a form I require the validation on the required-attribute to be executed, which works fine. To cancel such a form I use the attribute immediate="true" on the p:commandbutton , which makes its action happen during the Apply Request Values -Phase as addressed here: How to skip validation when a specific button is clicked? However, for large forms I want to provide the user with a Save-Button, so he can proceed later. For just saving the current state I also want to ignore the validation of the required

Android onActivityResult NEVER called

人盡茶涼 提交于 2019-11-27 16:23:01
my onActivityResult method is never called. am using android 2.2 I am using a Tabhost, where TabHosts contain TabGroups which contain individual Activities. One of my individual activity runs the following intent Intent intent = new Intent(); intent.setType("image/*"); intent.setAction(Intent.ACTION_GET_CONTENT); startActivityForResult(Intent.createChooser(intent, "Select Picture"), 0); this loads my gallery apps, I use the default android gallery to select one image and when I return my onActivityResult is not called my activity. It looks like this - and I put a breakpoint at if(resultCode ==

aspectj-maven-plugin not covered by lifecycle in Kepler

a 夏天 提交于 2019-11-27 16:08:15
问题 I've just downloaded the OEPE (Kepler) and installed m2e and m2e-wtp connectors. I found out that under this path: Preferences ->Maven->Lifecycle mappings->Open workspace lifecycle mapping data there is a preconfigured xml file which says that maven should ignore the compile goal for AspectJ and I assume that's why the AspectJ runtime libraries are not added to the project hence the project is not recognized as an AspectJ project by eclipse. <?xml version="1.0" encoding="UTF-8"?>

Saving Activity State in the onPause

谁说胖子不能爱 提交于 2019-11-27 15:48:40
问题 I have a variable that I have successfully saved and restored using onSaveInstanceState @Override protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); // the UI component values are saved here. outState.putDouble("VALUE", liter); Toast.makeText(this, "Activity state saved", Toast.LENGTH_LONG).show(); } But this only works if the activity is destroyed. I want to save the same variable by overriding the onPause() method and getting back when the activity is