android-intent

SINGLE_TOP | CLEAR_TOP seem to work 95% of the time. Why the 5%?

拈花ヽ惹草 提交于 2019-12-22 01:56:49
问题 I have a nearly-finished application with a non-trivial activity structure. There are push notifications associated with this app, and selecting the notification entry is supposed to bring up a specific activity regardless of whether the app is foreground/background/not active. If the app is not active, I have been able to successfully start the app and auto-navigate to the appropriate part. However, when the app is active, I have a problem. I will present a simplified version of the issue,

What is the difference between getExtras and getBundleExtras?

非 Y 不嫁゛ 提交于 2019-12-22 01:33:52
问题 Could someone please explain to me what is the difference between getExtras() and getBundleExtras() ? 回答1: getBundleExtra("String") gets a bundle named String . getExtras() gets a bundle with all of the items placed into the array. A bundle can be placed using a putExtra(Bundle, String tag) command, so the getBundleExtra() will return that value. 回答2: Worth notting is the fact that getExtras() returns copy of the all items placed in the intent, its implementation looks like this: 4433 public

How to Receive SMS Only From One Specific Number (Other SMSs Go to Phone's Inbox)

99封情书 提交于 2019-12-22 01:03:06
问题 My program can successfully send and receive SMS messages. Now I want to receive SMS in my program only from a specific phone number while messages from all other numbers go to the phone's inbox. The code that I use is below. It doesn't work and every SMS message goes to the phone's inbox. I think msg_from in SmsReceiver method, could not get value in for loop and is always null . MainActivity .java public class MainActivity extends Activity { private TextView showSms; private String

Get the number I am calling in Android

百般思念 提交于 2019-12-22 00:35:13
问题 I need to get the number that I am calling from my Android device programmatically. What I'm doing now is the following: I listen for android.intent.action.PHONE_STATE being broadcasted which means that either I am being called or am calling (or receiving an SMS etc). In a BroadcastReceiver I retrieve the extra incoming_number from the intent. Sadly I cannot get the number which is being called if I initiate the call though. How can I do this? 回答1: You need to use the Intent android.intent

How to close entire application?

自古美人都是妖i 提交于 2019-12-22 00:30:04
问题 I am beginner in android. When i click a Button KILL selected apps to close or kill a Particular(Running) Application or Selected Application. I Know it is possible. But how to work out it. My Sample UI is http://answers.oreilly.com/index.php?app=core&module=attach&section=attach&attach_rel_module=post&attach_id=555 I am try to use some code. But all the codes can be used to close only for activities. Not Closed Application. May i tried to refer some stackoverflow answers. But i am not

Android Studio: Passing multiple values using intent PROVIDES ONLY 1 VALUE?

狂风中的少年 提交于 2019-12-22 00:13:00
问题 I am trying to make a quiz where users choose an answer in each activity, and the final page provides an answer based on the chosen options. Therefore, I want to pass these values to the final activity, but only the last chosen value seems to show. First Activity: public class Quiz extends Activity { Button btn; RadioGroup rg; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.quiz); btn = (Button) findViewById(R.id

How to provide Context to call necessary functions in my own utility class

谁说我不能喝 提交于 2019-12-22 00:09:24
问题 Sometimes I need to provide a Context object to call specific functions, such as Intent intent = new Intent(context, MyClass.class); in order to start a service context.startService(intent); Or, provide a Context object to do a query Cursor cursor = context.managedQuery(uri, projection, null, null, null); If this is done in a UI class which extends Activity, that's fine. However, If I want to create my own utility class (a singleton) that doesn't extend anything and call these functions, I

how to use the intent anchor to launch my app with extra data(parameters) in android

不羁岁月 提交于 2019-12-21 23:59:30
问题 I have ever tried to launch my app using URI schema in javascript like this: window.location = "myapp://api/image?imageurl=hogehoge" but it failed in android.I don't know why. it's ok in iphone... so I changed to use the intent anchor to launch my app in android as described here. I'm able to get it to launch my app using this syntax, <a href="intent://#Intent;scheme=http;package=com.example.myapp;end">Launch my app</> but if I use the intent anchor , how can I pass the extra data ("api/image

Instant Apps: “You should have at least one active APK that is mapped to site 'sample.com' via a web 'intent-filter' ” when pushing to production

故事扮演 提交于 2019-12-21 23:52:52
问题 I'm getting the error message when releasing instant-app to production. I've read this post here: You should have at least one active APK that is mapped to site 'sample.com' via a web 'intent-filter' and this is a bit more specific. The answer in the above link states: Upload installable APK in alpha, beta or production with same HOST web 'intent-filter'. I uploaded an installable apk w/ the intent-filter to alpha and that the error message went away when releasing my instant-app to pre

How to get Activity Class from intent filter

北战南征 提交于 2019-12-21 23:37:04
问题 Suppose there is an application with package name com.example . The application has an activity which has an intent filter android.intent.action.SEND Now I want to programatically find the component class that supports the above intent filter. This code filters all the classes that matches ACTION_SEND. Intent sendIntent = new Intent(); sendIntent.setAction(Intent.ACTION_SEND); sendIntent.putExtra(Intent.EXTRA_TEXT, "This is my text to send."); sendIntent.setType("text/plain"); startActivity