android-event

Want to Access Power Button events in android

放肆的年华 提交于 2019-11-28 00:14:11
i=0; public boolean onKeyDown(int keyCode, KeyEvent event) { System.out.println("In Key Down Method." + event.getKeyCode()); if (event.getKeyCode() == KeyEvent.KEYCODE_POWER) { i++; System.out.println("Power button pressed."); if (i == 2) { System.out.println("Power button pressed continuoulsy 3 times."); Toast.makeText(MainActivity.this, "Power button pressed " + i + " times.", Toast.LENGTH_SHORT).show(); } else { System.out.println("Power button pressed continuoulsy " + i + " times."); Toast.makeText(MainActivity.this, "Power button pressed " + i + " times.", Toast.LENGTH_SHORT).show(); } }

SlidingUpPanelLayout and ScrollView

人盡茶涼 提交于 2019-11-27 20:19:20
I have a SlidingUpPanelLayout that holds a image as a top view, and a view pager that needs to slide. The viewpager has 3 fragments and two of them are list views. So I want to be able to expand the view pager on pulling up, and once the view pager is up I want to be able to scroll the scrollviews inside the fragments. But when pulling down on the scrollview in case there is no more to scroll, I want to start collapsing the viewpager . So please suggest how to make the SlidingUpPanelLayout collapse on pulling the scrollview in case there is no more contents to scroll? Here I post some of my

Receiving onTouch and onClick events with Android

陌路散爱 提交于 2019-11-27 16:38:54
问题 I have a view that need to process onTouch gestures and onClick events. What is the proper way to achieve this? I have an onTouchListener and an onClickListener set on the view. Whenever I do touch the view, first the onTouch event is triggered and later the onClick . However, from the onTouch event handler I have to return either true or false . Returning true means that the event is being consumed, so the android event system will not propagate the event any further. Therefore, an onClick

detecting android softkeyboard show/hide events

拟墨画扇 提交于 2019-11-27 15:03:47
问题 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);

Android get value of the selected radio button

自闭症网瘾萝莉.ら 提交于 2019-11-27 13:55:53
I have a RadioGroup rg1 and I want to get the value of the selected radio button. I know that I can get the id of the selected radio button by using: if(rg1.getCheckedRadioButtonId()!=-1) int id= rg1.getCheckedRadioButtonId() that gives me the id , but I want the value of that button. You need to get the radio button at that index, then get the value of the text of that button. Try this code below. if(rg1.getCheckedRadioButtonId()!=-1){ int id= rg1.getCheckedRadioButtonId(); View radioButton = rg1.findViewById(id); int radioId = radioGroup.indexOfChild(radioButton); RadioButton btn =

Listening WIFI state

北城以北 提交于 2019-11-27 07:00:16
问题 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

android: EXDATE format when adding a calendar event

喜你入骨 提交于 2019-11-27 06:55:18
问题 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

How can I send key events in android?

倖福魔咒の 提交于 2019-11-27 05:42:06
问题 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? 回答1: BaseInputConnection mInputConnection = new

How to distinguish between move and click in onTouchEvent()?

寵の児 提交于 2019-11-27 00:12:19
In my application, I need to handle both move and click events. A click is a sequence of one ACTION_DOWN action, several ACTION_MOVE actions and one ACTION_UP action. In theory, if you get an ACTION_DOWN event and then an ACTION_UP event - it means that the user has just clicked your View. But in practice, this sequence doesn't work on some devices. On my Samsung Galaxy Gio I get such sequences when just clicking my View: ACTION_DOWN, several times ACTION_MOVE, then ACTION_UP. I.e. I get some unexpectable OnTouchEvent firings with ACTION_MOVE action code. I never (or almost never) get sequence

SlidingUpPanelLayout and ScrollView

爷,独闯天下 提交于 2019-11-26 20:22:03
问题 I have a SlidingUpPanelLayout that holds a image as a top view, and a view pager that needs to slide. The viewpager has 3 fragments and two of them are list views. So I want to be able to expand the view pager on pulling up, and once the view pager is up I want to be able to scroll the scrollviews inside the fragments. But when pulling down on the scrollview in case there is no more to scroll, I want to start collapsing the viewpager . So please suggest how to make the SlidingUpPanelLayout