android-intent

How to get the listitem text value when click on it?

£可爱£侵袭症+ 提交于 2020-01-01 12:14:50
问题 I have a listitem and I would like to get the clicked item text value. The following codes is not work for me. It work fine, When I change the following line: String fullname = (String) l.getItemAtPosition(position); To: String fullname = "Hello world"; Thanks for your help. @Override protected void onListItemClick(ListView l, View v, int position, long id) { super.onListItemClick(l, v, position, id); String fullname = (String) l.getItemAtPosition(position); Intent bucket = new Intent(SQLView

Send data from Service back to my activity

被刻印的时光 ゝ 提交于 2020-01-01 12:12:14
问题 I have an activity that creates an intent, puts some extras with putExtra() and calls the startService(intent) to start a service. This service calculates some stuff based on the extras and then I want to send the result back to the activity. In which way can I do this? I tried to create an intent on my service and broadcast it using sendBroadcast(). I have a broadcastReceiver on the activity but Im not sure if I register it correctly. Im confused! Is there any other way to do so? Something

Custom chooser activity: SecurityException UID n does not have permission to content:// uri

人盡茶涼 提交于 2020-01-01 12:06:34
问题 I'm building a Chooser app that replaces the native Android Share dialog. It works fine except when I try to share an image from Chrome via longpress image > share image. I found that Google+ doesn't catch the exception (it crashes) so I can have a look at it via Logcat: Do an image search on Google. Select an image (this should show the preview) Longpress the image Choose "Share image" My chooser activity pops up Select Google+ Google+ crashes with this error: java.lang.SecurityException:

Custom chooser activity: SecurityException UID n does not have permission to content:// uri

主宰稳场 提交于 2020-01-01 12:05:06
问题 I'm building a Chooser app that replaces the native Android Share dialog. It works fine except when I try to share an image from Chrome via longpress image > share image. I found that Google+ doesn't catch the exception (it crashes) so I can have a look at it via Logcat: Do an image search on Google. Select an image (this should show the preview) Longpress the image Choose "Share image" My chooser activity pops up Select Google+ Google+ crashes with this error: java.lang.SecurityException:

Android emulate/send ACTION_MEDIA_BUTTON intent

强颜欢笑 提交于 2020-01-01 12:00:16
问题 I am trying to control universal music playback (play/pause, skip etc.) by emulating headset music controls. Is there a way to broadcast the ACTION_MEDIA_BUTTON intent? I tried the regular way with sendBroadcast() but it didn't work. Is this possible? 回答1: Try this long eventtime = SystemClock.uptimeMillis(); Intent downIntent = new Intent(Intent.ACTION_MEDIA_BUTTON, null); KeyEvent downEvent = new KeyEvent(eventtime, eventtime, KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE, 0);

Launch application when GCM notification received

旧巷老猫 提交于 2020-01-01 11:33:08
问题 I have GCM notification implementation. I know that the client application receives the notification whether it is in the foreground, background or killed state. What I would like to know is, how can I launch my application on notification received, when the application is in the killed state? 回答1: In the message receiver, I do the following: final Intent notificationIntent = new Intent(context, YourActivity.class); notificationIntent.setAction(Intent.ACTION_MAIN); notificationIntent

Android: ACTION_BATTERY_LOW not triggered in emulator. Receiver registered in code, not manifest

耗尽温柔 提交于 2020-01-01 10:46:13
问题 I have seen posts where it was mentioned registerReceiver has to be called (not defined in manifest) to receive ACTION_BATTERY_LOW intent. public class MainActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { //.... registerReceiver(new BatteryLevelReceiver(), new IntentFilter( Intent.ACTION_BATTERY_LOW)); } // ....... } BroadcastReceiver public class BatteryLevelReceiver extends BroadcastReceiver { private static final String TAG = BatteryLevelReceiver

How to pass spinner data from one activity to another ?

天大地大妈咪最大 提交于 2020-01-01 10:16:13
问题 This code is not reading the value from the spinner it's reading only the first value always, btnResult.setOnClickListener(new View.OnClickListener() { final String USN = spnConversions.getSelectedItem().toString(); @Override public void onClick(View v) { Intent i = new Intent(getApplicationContext(), DatabaseResult.class); i.putExtra("getData",USN.toString()); startActivity(i); } }); 回答1: Why you are using onClickListener for Spinner ? You should use OnItemSelectedListener() for Spinner see

Checking Android System Security Notification Access setting programmatically

陌路散爱 提交于 2020-01-01 10:15:19
问题 Is there a way to check whether the below setting is enabled or disabled programmatically in Android? Settings > Security > Device Administration > Notification Access > My App Currently I'm invoking the settings dialog from my app through the below method but if the settings are already enabled then I dont want to present this settings. Intent intent = new Intent("android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS"); startActivity(intent); 回答1: Make it simple if (Settings.Secure

Android Widget stops working randomly

随声附和 提交于 2020-01-01 10:06:52
问题 I have been working with this problem for three days now and I've looked at every single question on here for an answer. I have a widget with a button on it and all I would like it to do is start a service everytime it is clicked. The problem is that the button stops working randomly. I can't recreate it at all and I have no idea what causes it. My service calls stopSelf(); but I have had this problem with a broadcast receiver also so I believe the problem to be in the widget and not in the