android-event

How to Prevent Accidental App Exit w/in Android Fragments/Activities?

我的未来我决定 提交于 2019-12-03 09:16:00
How Do I Prevent Accidental App Exit w/in Android? IE: When the he/she presses the back button and reaches the last activity in the BackStack, show a toast to ask if the user wants to exit using the onBackPressed() method. Also, It needs to function with backStacks for fragments. This functionality can easily be implemented by overriding main activity's onBackPressed() method. In this example when user presses back button then the app will display a toast for 4 seconds on which time a new back press terminates the app immediately. ref You can put it in a BaseActivity that extends Activity like

How to prevent onTouch for parent Linear Layout from executing multiple times child?

匆匆过客 提交于 2019-12-02 12:43:57
On touch event for a lienar layout multiple screens pops up. It seems that the ontouch event gets fired twice for each child element of the linear layout. How can I prevent this from firing twice. On click event for the same linear layout causes, the linear layout onclick event to be fired on second click and not on the first click. I am not understanding where I am going wrong. Please help. -- XML <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="center_vertical" android:orientation="vertical" > <LinearLayout android:layout_width="match

RadioGroup doesn't work properly

人走茶凉 提交于 2019-12-02 04:32:15
问题 I want to give the user four choices, the first and second choices on a row and the third and fourth choices on another row. My problem is when the application starts I can select more than one choice, but I don't want that. This is my xml layout: <RadioGroup android:id="@+id/rgAnswerQuestionChoices" android:layout_width="wrap_content" android:layout_height="wrap_content" > <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android

RadioGroup doesn't work properly

南笙酒味 提交于 2019-12-02 02:54:17
I want to give the user four choices, the first and second choices on a row and the third and fourth choices on another row. My problem is when the application starts I can select more than one choice, but I don't want that. This is my xml layout: <RadioGroup android:id="@+id/rgAnswerQuestionChoices" android:layout_width="wrap_content" android:layout_height="wrap_content" > <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="match_parent" android:orientation="horizontal" > <RadioButton android:id="@+id

How to exit the android application on backpress?

落花浮王杯 提交于 2019-12-01 13:40:39
The situation could be like say, I've 5 activities. Say Main activity, Activity 1, Activity 2, Activity 3 and Activity 4. One can use the Activity 1,2,3 & 4 directly with the help of buttons so inserted on Main Activity layout. Situation: User enters into the Main Activity, and presses a button to enter into Activity 2. Then he back presses and comes back to Main Activity. from there he now enters Activity 3 with the help of another button and similarly when he presses back button he enters into Main Activity. Main Activity --> Activity 2 --> Main Activity --> Activity 3 --> Main Activity.

Show Dialog using PendingIntent

旧城冷巷雨未停 提交于 2019-11-29 04:29:32
I am working on Calender Events reminder . There is no native Calender events reminder in Android so user install different calender apps. Now these apps can be different on reminding events like on reminder notifications can be shown. Now I want that I set an event programmatically in these event calender apps and on time reached not show any notification rather a pop up message will be shown with alarm like sound. At that I using a code from that site . Its working but it showing reminders in form of notifications. Here is code: OnReceive void doReminderWork(Intent intent) { Long rowId =

detecting android softkeyboard show/hide events

吃可爱长大的小学妹 提交于 2019-11-28 23:29:22
I am trying to detect showKeyboard and hidekeyboard events on phonegap. For that purpose, on deviceready event I placed following code: bindEvents: function() { document.addEventListener('deviceready', this.onDeviceReady, false); }, // deviceready Event Handler // // The scope of 'this' is the event. In order to call the 'receivedEvent' // function, we must explicity call 'app.receivedEvent(...);' onDeviceReady: function() { document.addEventListener("menubutton",app.onMenuKeyPress,false); document.addEventListener("backbutton",navigateBack,false); document.addEventListener("hidekeyboard",

Listening WIFI state

こ雲淡風輕ζ 提交于 2019-11-28 12:26:48
I want to set listener to listen on wireless state,can anyone help me with my code import android.telephony.PhoneStateListener; import android.telephony.TelephonyManager; ... TelephonyManager wTelephonyManager; ... wTelephonyManager=(TelephonyManager)getSystemService(Context.WIFI_SERVICE); wTelephonyManager.listen(new PhoneL(),PhoneStateListener.LISTEN_DATA_CONNECTION_STATE); connManager = (ConnectivityManager) getSystemService(CONNECTIVITY_SERVICE); //here is the event that i use that i want to listen for wifi change, and the above code is all in onCreate{} class PhoneL extends

android: EXDATE format when adding a calendar event

泪湿孤枕 提交于 2019-11-28 12:23:41
Can someone explain how to use EXDATE when adding event to android calendar? The documentation is pretty unclear about the format in which the EXDATE should be put. I tried many formats, these are some of them: values.put(Events.EXDATE, "TZID=Europe/London:20130116T080000"); values.put(Events.EXDATE, "20130116T080000Z"); values.put(Events.EXDATE, "20130116T080000"); values.put(Events.EXDATE, "20130116"); but none of them works. Any idea how to make an event not appear on a particular date, if by the RRULE it should appear? The correct format is: values.put(Events.EXDATE, "20130116T080000Z");

How can I send key events in android?

天大地大妈咪最大 提交于 2019-11-28 06:38:17
I am macking a custom navigation bar to Android 4.0.3.r1 and want to send key events like "Home" and "Back". My application is not a system therefore: IWindowManager mWindowManager = IWindowManager.Stub.asInterface( ServiceManager.getService(Context.WINDOW_SERVICE)); mWindowManager.injectKeyEvent( ev, false ); It doesn't work, because I can not get android.permission.INJECT_EVENTS from not system application. How can I do this? Roman Trokhymets BaseInputConnection mInputConnection = new BaseInputConnection(targetView, true); mInputConnection.sendKeyEvent(new KeyEvent(...)); you can try this