android-intent

What does setAction () do for intent (Broadcast)

泄露秘密 提交于 2020-07-06 10:14:27
问题 What does setAction () do in intent (Service) I don't really get what setAction () does, I mostly found it in " service to activity data passing " example. Can the string be set freely ?. What does it do exactly ? When a broadcast intent is created, it must include an ACTION STRING in addition to optional data and a category string. As with standard intents, data is added to a broadcast intent using key-value pairs in conjunction with the putExtra() method of the intent object. The optional

Set a selected audio file as ringtone

喜欢而已 提交于 2020-07-05 12:37:23
问题 I am developing an application: I am trying to set an audio file as a ringtone. I saw many posts, but no one actually helped me, so I decided to ask this question. I use this code when the Button is clicked: @Override public void onClick(View v) { Intent intent = new Intent(); intent.setAction(Intent.ACTION_GET_CONTENT); intent.setType("audio/*"); startActivityForResult(Intent.createChooser(intent, "Choose Sound File"), Audio); } in onActivityResult I am trying to get the file path and then

Implicit Intent is not working due to context issue

我只是一个虾纸丫 提交于 2020-07-04 04:26:22
问题 Here is my code :- Favourite Activity import android.content.Context import android.content.Intent import android.os.Bundle import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import android.widget.ImageView import android.widget.TextView import android.widget.Toast import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.widget.Toolbar import androidx.core.content.ContextCompat.startActivity import androidx.recyclerview.widget

How to check if an intent can be handled on API 30+ (Android 10+, R)?

≡放荡痞女 提交于 2020-06-29 03:58:39
问题 Below 30 API there were two methods I could use to check if intent can be handled by some app activity: fun Intent.canBeHandled(packageManager: PackageManager): Boolean { return resolveActivity(packageManager) != null } fun PackageManager.isIntentCanBeHandled(intent: Intent): Boolean { val infos = queryIntentActivities(intent, 0) return infos.isNotEmpty() } But when I test on Pixel 3 API 30 Emulator it doesn't work as expected, e.g. queryIntentActivities() returns usually 0 or 1 (e.g. 1 for

Android: Intent.EXTRA_ALLOW_MULTIPLE allows only single picking

邮差的信 提交于 2020-06-25 08:16:36
问题 I want to open multiple images from the Android gallery using "Intent.EXTRA_ALLOW_MULTIPLE" intent filter: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) { final Intent intent = new Intent(Intent.ACTION_GET_CONTENT); intent.setType("image/*"); intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true); intent.putExtra(Intent.EXTRA_LOCAL_ONLY, true); startActivityForResult(Intent.createChooser(intent, "Add images"), SELECT_MULTIPLE_IMAGES); } But whatever app I use (native gallery,

Android: Intent.EXTRA_ALLOW_MULTIPLE allows only single picking

喜你入骨 提交于 2020-06-25 08:15:32
问题 I want to open multiple images from the Android gallery using "Intent.EXTRA_ALLOW_MULTIPLE" intent filter: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) { final Intent intent = new Intent(Intent.ACTION_GET_CONTENT); intent.setType("image/*"); intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true); intent.putExtra(Intent.EXTRA_LOCAL_ONLY, true); startActivityForResult(Intent.createChooser(intent, "Add images"), SELECT_MULTIPLE_IMAGES); } But whatever app I use (native gallery,

Android: Intent.EXTRA_ALLOW_MULTIPLE allows only single picking

∥☆過路亽.° 提交于 2020-06-25 08:14:00
问题 I want to open multiple images from the Android gallery using "Intent.EXTRA_ALLOW_MULTIPLE" intent filter: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) { final Intent intent = new Intent(Intent.ACTION_GET_CONTENT); intent.setType("image/*"); intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true); intent.putExtra(Intent.EXTRA_LOCAL_ONLY, true); startActivityForResult(Intent.createChooser(intent, "Add images"), SELECT_MULTIPLE_IMAGES); } But whatever app I use (native gallery,

intent.putExtra() in pending intent not working

家住魔仙堡 提交于 2020-06-24 05:43:01
问题 I am passing a pending intent through alarmreceiver, from a service class. But, after the pendingIntent fires, the intent.putExtra() information is not being received by the broadcastreceiver class. Here is my code for firing the pendingIntent Intent aint = new Intent(getApplicationContext(), AlarmReceiver.class); PendingIntent pendingIntent = PendingIntent.getBroadcast(getApplicationContext(), id, aint, PendingIntent.FLAG_UPDATE_CURRENT); aint.putExtra("msg", msg); aint.putExtra("phone",

java.lang.NullPointerException: Attempt to invoke virtual method 'android.app.ActivityThread$ApplicationThread

十年热恋 提交于 2020-06-18 03:29:23
问题 I know this may be a duplicate but my situation is different which requires some explanation on this specific issue. I'm getting the error : java.lang.NullPointerException: Attempt to invoke virtual method 'android.app.ActivityThread$ApplicationThread android.app.ActivityThread.getApplicationThread()' on a null object reference In the onClick the method addEvent is called from the class MyCalendar button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) {

No response from intent to prompt user to set default handler for SMS

﹥>﹥吖頭↗ 提交于 2020-06-17 14:22:12
问题 I'm currently having trouble getting the app to send the user a dialogue to set the default handler for SMS on API 29. I initially followed https://developer.android.com/guide/topics/permissions/default-handlers. It didn't work so I looked around and saw this: How to set Default SMS prompt for KitKat. So I followed https://android-developers.googleblog.com/2013/10/getting-your-sms-apps-ready-for-kitkat.html and added the snippet to my manifest XML (without actual implementation, as the