android-intent

How to programmatically share multiple files of different MIME types within the same Android intent?

这一生的挚爱 提交于 2021-02-20 03:51:43
问题 I am working on an Android application that is already successfully sharing a generated PDF file via Bluetooth using the following method: public static void sharePdfFile(Context ctx, String pathAndFile) { try { Intent share = new Intent(Intent.ACTION_SEND); share.setPackage("com.android.bluetooth"); share.setType("application/pdf"); share.putExtra(Intent.EXTRA_STREAM, Uri.parse(pathAndFile)); share.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); ctx.startActivity(share); } catch (Exception e) {

How to programmatically share multiple files of different MIME types within the same Android intent?

匆匆过客 提交于 2021-02-20 03:51:22
问题 I am working on an Android application that is already successfully sharing a generated PDF file via Bluetooth using the following method: public static void sharePdfFile(Context ctx, String pathAndFile) { try { Intent share = new Intent(Intent.ACTION_SEND); share.setPackage("com.android.bluetooth"); share.setType("application/pdf"); share.putExtra(Intent.EXTRA_STREAM, Uri.parse(pathAndFile)); share.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); ctx.startActivity(share); } catch (Exception e) {

Using ADB to launch an activity while using putExtra

前提是你 提交于 2021-02-19 05:25:08
问题 I've been trying to use the Android Documentation to determine how to start an activity with putExtra. My putExtra value is of type String and I've tried numerous combinations of "true", "1", putting the string in quotes. I've tried switching the flags to "-n", "-a", etc... Can somebody point out what I'm doing wrong here? I've ready many other articles but they are usually for some built in intent. I'm starting my own custom intent. Starting an intent with a string key. -e|--es <EXTRA_KEY>

Start new Activity outside the Activity context.

三世轮回 提交于 2021-02-19 01:39:11
问题 I tried to start an Activity and close other in my AsyncTask class ( onPostExecute() ). My code : Intent i = new Intent(parentActivity, ThunderHunter.class); c.startActivity(i); parentActivity.finish(); But it doesn't work, logcat shows : 08-01 18:01:27.640: E/AndroidRuntime(12398): android.util.AndroidRuntimeException: Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want? 08-01 18:01:27.640: E/AndroidRuntime(12398)

Programmatically open app in split screen

时光总嘲笑我的痴心妄想 提交于 2021-02-18 19:19:21
问题 How do I open another app in a split screen in the android N (SDK 24)? In the documentation I found this: Launch New Activities in Multi-Window Mode When you launch a new activity, you can hint to the system that the new activity should be displayed adjacent to the current one, if possible. To do this, use the flag Intent.FLAG_ACTIVITY_LAUNCH_TO_ADJACENT. Passing this flag requests the following behaviour: If the device is in split-screen mode, the system attempts to create the new activity

Programmatically open app in split screen

笑着哭i 提交于 2021-02-18 19:19:12
问题 How do I open another app in a split screen in the android N (SDK 24)? In the documentation I found this: Launch New Activities in Multi-Window Mode When you launch a new activity, you can hint to the system that the new activity should be displayed adjacent to the current one, if possible. To do this, use the flag Intent.FLAG_ACTIVITY_LAUNCH_TO_ADJACENT. Passing this flag requests the following behaviour: If the device is in split-screen mode, the system attempts to create the new activity

How to display image with intent.ACTION_VIEW

拈花ヽ惹草 提交于 2021-02-18 18:56:37
问题 My grammar can run at android 5.1 but is not working at android 7.1.... File file = new File(Environment.getExternalStorageDirectory(), "Pictures/1481853170451.jpg"); Toast.makeText(MainActivity.this, file.getPath(), Toast.LENGTH_LONG).show(); Uri path = Uri.fromFile(file); if (file.exists()) { Intent intent = new Intent(); intent.setAction(android.content.Intent.ACTION_VIEW); intent.setDataAndType(path, "image/*"); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); try { this.startActivity

How to display image with intent.ACTION_VIEW

一曲冷凌霜 提交于 2021-02-18 18:56:23
问题 My grammar can run at android 5.1 but is not working at android 7.1.... File file = new File(Environment.getExternalStorageDirectory(), "Pictures/1481853170451.jpg"); Toast.makeText(MainActivity.this, file.getPath(), Toast.LENGTH_LONG).show(); Uri path = Uri.fromFile(file); if (file.exists()) { Intent intent = new Intent(); intent.setAction(android.content.Intent.ACTION_VIEW); intent.setDataAndType(path, "image/*"); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); try { this.startActivity

Notification bring app to front without change activity

家住魔仙堡 提交于 2021-02-18 04:36:41
问题 I want to create notification that when it clicked will bring my app to front but without changing (reload or navigate out) the last activity that was shown. I tried: setContentIntent(PendingIntent.getActivity(context, 0, new Intent(context, MainActivity.class), Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT)) But in the new Android 4.3 the application brought to front, but its also start a new instance of MainActivity , and I don't want this. I want that my app will continue from the last activity

How to Pass custom object via intent in kotlin

旧街凉风 提交于 2021-02-15 09:14:29
问题 fun launchNextScreen(context: Context, people: People): Intent { val intent = Intent(context, NextScreenActivity::class.java) intent.putExtra(EXTRA_PEOPLE, (Parcelable) people) //intent.putExtra(EXTRA_PEOPLE, people as Parcelable) //intent.putExtra(EXTRA_PEOPLE, people) // tried above all three ways return intent } I tried the above code to pass an instance of the People class via intent using kotlin, but I am getting an error. What am I doing wrong? 回答1: First, make sure the People class