android-intent

Android Intent defaults - detect and clear

吃可爱长大的小学妹 提交于 2019-12-29 07:19:28
问题 Is there a way to detect that a phone has a default application chosen for an intent such as android.intent.action.SEND ? Is there a way to clear the default application via code? I'd like to give the user an option to remove the default or at least show a screen telling them how to do it manually, if I can detect it. 回答1: Take a look at PackageManager. With it, you can determine how an Intent will be handled with resolveActivity(intent). It looks like the method for clearing the preference

IntentNotFoundException for TextToSpeech.Engine.ACTION_INSTALL_TTS_DATA

☆樱花仙子☆ 提交于 2019-12-29 07:08:28
问题 I am trying to implement text to speech by following this article on the Android Developers Blog. It suggests the following code for installing text to speech data if it is not supported. Intent installIntent = new Intent(); installIntent.setAction(TextToSpeech.Engine.ACTION_INSTALL_TTS_DATA); startActivity(installIntent); This throws an Exception : ActivityNotFoundException : No activity found to handle Intent However, I am using the code here to determine the the intent is actually

Android: Null Pointer Exception when calling new intent

杀马特。学长 韩版系。学妹 提交于 2019-12-29 07:00:07
问题 I am receiving an error when trying to call new activity through an intent: java.lang.NullPointerException: Attempt to invoke virtual method 'android.app.ActivityThread$ApplicationThread android.app.ActivityThread.getApplicationThread()' on a null object reference My Activity has a button, and when clicked, it goes to this method: public void onClickChangeActivity() { Intent intent = new Intent(context , Details.class); startActivity(intent); } public static Context context is created in the

Android, Intent.FLAG_ACTIVITY_CLEAR_TOP seems doesn't work?

风格不统一 提交于 2019-12-29 06:30:22
问题 In my menu I have some items. Home is an item of it that I want to be root of my application and whenever user clicks on it, Android clear stack and then come back to main screen. This is my code: menu.setOnItemClickedListener(new MenuClickedListener() { public void eventOccured(int id) { Intent intent = null; switch(id) { case 1: intent = new Intent(context, More.class); break; case 2: intent = new Intent(context, FavoriteScreen.class); break; case 3: intent = new Intent(context,

How to get the data from “share picture via” dialog on Android?

夙愿已清 提交于 2019-12-29 06:24:12
问题 I've added the intent-filter. And when I tap "share" in the Gallery, it will launch my activity. <intent-filter> <action android:name="android.intent.action.SEND" /> <category android:name="android.intent.category.DEFAULT" /> <data android:mimeType="image/*" /> </intent-filter> But I don't know how to get the correct data from the current intent. Any helps? EDIT: Sorry, missing "picture" in the question 回答1: I found the answer. Uri imageUri = (Uri) getIntent().getExtras().get(Intent.EXTRA

Launch Location Settings intent from preferences XML file

£可爱£侵袭症+ 提交于 2019-12-29 05:51:57
问题 I want to launch System's Location Settings from an Intent . I know that programmatically it goes like this Intent viewIntent = new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS); startActivity(viewIntent); but I need to do it from the XML of a Preference . I try like this <Preference android:title="@string/pref_title" > <intent android:action="android.settings.ACTION_LOCATION_SOURCE_SETTINGS" /> </Preference> but it does not work, I always get an ActivityNotFoundException

How to keep bluetooth connection in background?

百般思念 提交于 2019-12-29 05:25:35
问题 i am writing a bluetooth app communicating with a bluetooth module. Actually it works very well. But i want the connection to stay established also while the app is in background and other apps are used, so that another activity like incoming sms or something else can trigger my app in background to send messages to my device. Until now i am very confused how to do this. Can anyone give me advice? I also checked this: Background Bluetooth App - Threading? but it doesn't help me. Here is my

Passing Integer Between Activities and Intents in Android Is Always Resulting in Zero / Null

笑着哭i 提交于 2019-12-29 04:55:05
问题 I'm attempting to pass two integers from my Main Page activity (a latitude and longitude) to a second activity that contains an instance of Google Maps that will place a marker at the lat and long provided. My conundrum is that when I retrieve the bundle in the Map_Page activity the integers I passed are always 0, which is the default when they are Null. Does anyone see anything glaringly wrong? I have the following stored in a button click OnClick method. Bundle dataBundle = new Bundle();

Android Download Intent

孤者浪人 提交于 2019-12-29 04:28:09
问题 I was wondering what is the intent for downloading URLs? In the browser, it will download stuff with a little notification icon. I was wondering if I can use that intent (and what it is). 回答1: Applications can download files with the download manager just like the browser and gmail. This is available starting with Gingerbread. Your app needs the INTERNET permission to initiate a download. To save the file in the default Download directory it also needs the WRITE_EXTERNAL_STORAGE permission.

Android, How to send HTML email and force Android to send it through G-Mail not other applications?

牧云@^-^@ 提交于 2019-12-29 04:19:48
问题 I want to send email through my application. I need to send HTML based email just through G-Mail. I found following solutions that each of them has pros and cons. 1) Using Intent (Intent.ACTION_SEND). This is very simple way and I can see my body in HTML format but the problem is when I click on "Send email" button, so many applications like Facebook and Google+ pop up which are useless and I shouldn't show it in that list. This is its code: String html = "<!DOCTYPE html><html><body><a href=\