Coder Social home page Coder Social logo

itzmeanjan / intent Goto Github PK

View Code? Open in Web Editor NEW
95.0 3.0 60.0 23.56 MB

A simple Flutter plugin to deal with Android Intents, written with :heart:

License: MIT License

Kotlin 49.47% Objective-C 3.83% Dart 44.93% Ruby 1.76%
flutter dart flutter-plugin android intent android-intent android-intents android-activities

intent's Introduction

Warning I've stopped maintaining this project !

intent

A simple flutter plugin to deal with Android Intents - your one stop solution for Android Intents, written with ❤️.

Show some ❤️ by putting ⭐

intent tries to help you in launching another android activity using Android Intents. This Dart API replicates Android Intent API, so for detailed information on how to use it efficiently, when to send what kind of data, you may be interested in taking a look here, which explains things more elaborately.

intent is readily available for use.

what does it do ?

  • intent is your one stop solution for handling different Android Intents from Flutter app.
  • It provides an easy to use Dart API, which can be used to launch different kind of Android Activities
  • You can view / create documents
  • Pick document(s) from Document Tree
  • Open default Assist Activity
  • Perform a Web Search
  • Request definition of a certain string to default Assist Activity
  • Open image for editing / viewing
  • Share text / multimedia to another activity
  • Send Email to specific user, while also setting CC & BCC
  • Share multiple documents at a time
  • Sync system content
  • Translate text
  • Set Wallpaper
  • Open any URL
  • Open Dialer for calling a specific number
  • Can pick a contact from your default phone activity
  • Can capture a photo using default Camera Activity

latest addition

Newest Addition: You can pass extra data's type information, while invoking Intent.putExtra(String extra, dynamic data, {String type}) as optional named param type. You don't even need to hardcode type names as Strings, rather a class named TypedExtra has been given to developers, which has all currently supported type names as static variables. Consider using them. And last but not least, this is not a breaking change !!!

import 'package:intent/intent.dart' as android_intent;
import 'package:intent/extra.dart' as android_extra;
import 'package:intent/typedExtra.dart' as android_typedExtra;
import 'package:intent/action.dart' as android_action;

// more codes ...

android_intent.Intent()
        ..setAction(android_action.Action.ACTION_SHOW_APP_INFO)
        ..putExtra(android_extra.Extra.EXTRA_PACKAGE_NAME, "com.whatsapp", type: android_typedExtra.TypedExtra.stringExtra)
        ..startActivity().catchError((e) => print(e));

how to use it ?

Well make sure, you include intent in your pubspec.yaml.

Define a Term :

Intent()
        ..setAction(Action.ACTION_DEFINE)
        ..putExtra(Extra.EXTRA_TEXT, "json")
        ..startActivity().catchError((e) => print(e));

Show Desired Application Info :

Make sure you address app using its unique package id.

Intent()
        ..setAction(Action.ACTION_SHOW_APP_INFO)
        ..putExtra(Extra.EXTRA_PACKAGE_NAME, "com.whatsapp")
        ..startActivity().catchError((e) => print(e));

Show Application Preference Activity :

Intent()
        ..setAction(Action.ACTION_APPLICATION_PREFERENCES)
        ..startActivity().catchError((e) => print(e));

Launch Application Error Reporting Activity :

Intent()
        ..setAction(Action.ACTION_APP_ERROR)
        ..startActivity().catchError((e) => print(e));

Launch Default Assist Activity :

Intent()
        ..setAction(Action.ACTION_ASSIST)
        ..startActivity().catchError((e) => print(e));

Report Bug :

Intent()
        ..setAction(Action.ACTION_BUG_REPORT)
        ..startActivity().catchError((e) => print(e));

View a URI :

Which activity to be launched, depends upon type of URI passed.

In case of passing tel URI, opens dialer up.

Intent()
        ..setAction(Action.ACTION_VIEW)
        ..setData(Uri(scheme: "tel", path: "123"))
        ..startActivity().catchError((e) => print(e));

If you pass a mailto URI, it'll open email app.

Intent()
        ..setAction(Action.ACTION_VIEW)
        ..setData(Uri(scheme: "mailto", path: "[email protected]"))
        ..startActivity().catchError((e) => print(e));

In case of http/ https URI, opens browser up.

Intent()
        ..setAction(Action.ACTION_VIEW)
        ..setData(Uri(scheme: "https", host:"google.com"))
        ..startActivity().catchError((e) => print(e));

Dial a Number using Default Dial Activity :

Setting data using tel URI, will open dialer, number as input.

Intent()
        ..setAction(Action.ACTION_DIAL)
        ..setData(Uri(scheme: 'tel', path: '121'))
        ..startActivity().catchError((e) => print(e));

But if you're interested in opening dialer without any numbers dialer, make sure you don't set data field.

Intent()
        ..setAction(Action.ACTION_DIAL)
        ..startActivity().catchError((e) => print(e));

Calling a Number :

You can simply call a number, but make sure you've necessary permissions to do so.

Intent()
        ..setAction(Action.ACTION_CALL)
        ..setData(Uri(scheme: 'tel', path: '121'))
        ..startActivity().catchError((e) => print(e));

It'll always be a wise decision to use ACTION_DIAL, because that won't require any kind of permissions.

Create Precomposed Email :

Intent()
        ..setPackage("com.google.android.gm")
        ..setAction(Action.ACTION_SEND);
        ..setType("message/rfc822");
        ..putExtra(Extra.EXTRA_EMAIL, ["[email protected]"]);
        ..putExtra(Extra.EXTRA_CC, ["[email protected]"]);
        ..putExtra(Extra.EXTRA_SUBJECT, "Foo bar");
        ..putExtra(Extra.EXTRA_TEXT, "Lorem ipsum");
        ..startActivity().catchError((e) => print(e));

Create a Document :

Content type of document is set text/plain, category is CATEGORY_OPENABLE and file name is passed as an extra i.e. EXTRA_TITLE.

Intent()
        ..setAction(Action.ACTION_CREATE_DOCUMENT)
        ..setType("text/plain")
        ..addCategory(Category.CATEGORY_OPENABLE)
        ..putExtra(Extra.EXTRA_TITLE, "test.txt")
        ..startActivity().catchError((e) => print(e));

You can also set path of file using data field. But make sure data field is a valid path URI.

Edit Document :

You can edit image/ text or any other kind of data using appropriate activity.

Intent()
        ..setAction(Action.ACTION_EDIT)
        ..setData(Uri(scheme: 'content',
                path:
                'path-to-image'))
        ..setType('image/*')
        ..startActivity().catchError((e) => print(e));

Add a Contact to your Contact Database :

Intent()
        ..setAction('com.android.contacts.action.SHOW_OR_CREATE_CONTACT')
        ..setData(Uri(scheme: 'tel', path: '1234567890'))
        ..startActivity().catchError((e) => print(e));

Search for a Term :

Opens up a list of eligible candidates, which can provides search activity.

Intent()
        ..setAction(Action.ACTION_SEARCH)
        ..putExtra(Extra.EXTRA_TEXT, 'json')
        ..startActivity().catchError((e) => print(e));

Share Text/ Media :

Make sure you've set appropriate path URI for sharing documents/ media using EXTRA_STREAM and also set type properly.

Following one will share a plain text. For sharing html formatted text, set type to text/html.

Intent()
        ..setAction(Action.ACTION_SEND)
        ..setType('text/plain')
        ..putExtra(Extra.EXTRA_TEXT, 'json')
        ..startActivity().catchError((e) => print(e));

But if you're interested in creating a chooser i.e. all eligible candidates shown up system, which can handle this intent, make sure you set createChooser named parameter to true, which is by default false.

Send Email to certain ID while setting Content and CC/ BCC :

Intent()
        ..setAction(Action.ACTION_SENDTO)
        ..setData(Uri(scheme: 'mailto', path: '[email protected]'))
        ..putExtra(Extra.EXTRA_CC, ['[email protected]'])
        ..putExtra(Extra.EXTRA_TEXT, 'Hello World')
        ..startActivity().catchError((e) => print(e));

Translate a Text using default Assist Activity :

Intent()
        ..setAction(Action.ACTION_TRANSLATE)
        ..putExtra(Extra.EXTRA_TEXT, "I Love Computers")
        ..startActivity().catchError((e) => print(e));

Pick a Contact up from Phone :

  • Opens default Phone Activity and let user pick a contact up, selected contact will be returned as Future<List<String>> from startActivityForResult().
        Intent()
                ..setAction(Action.ACTION_PICK)
                ..setData(Uri.parse('content://contacts'))
                ..setType("vnd.android.cursor.dir/phone_v2")
                ..startActivityForResult().then((data) => print(data),
                onError: (e) => print(e));

Capture Image using default Camera activity :

Path to captured image can be grabbed from Intent().startActivityForResult().then(() { ... } ), which will be provided in form of List<String>, open file using that path, File(data[0]). Now you can work on that image file.

        Intent()
                ..setAction(Action.ACTION_IMAGE_CAPTURE)
                ..startActivityForResult().then((data) => print(data[0]), // gets you path to image captured
                onError: (e) => print(e));

image_capture_using_intent

If you're not interested in showing default activity launch animation, set following flag.

Intent()..addFlag(Flag.FLAG_ACTIVITY_NO_ANIMATION);

If you don't want this activity to be displayed in recents, set following flag.

Intent()..addFlag(Flag.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);

If you request for certain Activity and no eligible candidate was found, you'll receive one error message, which you can listen for using Future.catchError((e) {},) method.

PlatformException(Error, android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.SYSTEM_TUTORIAL }, null)

Currently a limited number of Actions are provided in Action class, but you can always use a string constant as an Action, which will help you in dealing with many more Activities.

Hoping this helps 😉

intent's People

Contributors

agniswarm avatar alexviquez avatar itzmeanjan avatar togiberlin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

intent's Issues

Intent action : ACTION_DELETE , App crashes after I hit cancel second time

I had implemented package deletion app and intend to use ACTION_DELETE and refreshing the page after deletion of the selected package on my list.

Sequence of steps:
1> Select the package and click on delete (which runs the below intent code),
2> Click Cancel , hit delete again and hit cancel button again.. This time App crashes
Attached is the logcat..
Intent_issue_LogCat.txt

Error reported:
java.lang.RuntimeException: Failure delivering result ResultInfo

Code to launch delete package :
android_intent.Intent()
..setAction(android_action.Action.ACTION_DELETE)
..setData(Uri.parse("package:${app.packageName}"))
..startActivityForResult().then((data) => print(data));

ACTION_DELETE doesn't work

Thanks for the great examples, well documented.
But I am stuck with a small issue.

android_intent.Intent()
    ..setAction(android_action.Action.ACTION_DELETE)
    ..setData(Uri.parse("package:com.exmaple.app"))
    ..startActivity().catchError((e) => print(e));

This doesn't work? Am I missing something? It doesn't log an error either.

RuntimeException picking contact

Launching lib/main.dart on Note 4 in debug mode...
✓ Built build/app/outputs/flutter-apk/app-debug.apk.
Error: ADB exited with exit code 1
Performing Streamed Install

Connecting to VM Service at ws://127.0.0.1:61073/sX4EAUGJxbU=/ws
D/AndroidRuntime(23277): Shutting down VM
E/AndroidRuntime(23277): FATAL EXCEPTION: main
E/AndroidRuntime(23277): Process: com.example.xxx, PID: 23277
E/AndroidRuntime(23277): java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=999, result=-1, data=Intent { dat=content://com.android.contacts/data/869 flg=0x1 }} to activity {com.example.xxx/com.example.xxx.MainActivity}: java.lang.IllegalArgumentException: Invalid column _data
E/AndroidRuntime(23277): 	at android.app.ActivityThread.deliverResults(ActivityThread.java:4398)
E/AndroidRuntime(23277): 	at android.app.ActivityThread.handleSendResult(ActivityThread.java:4440)
E/AndroidRuntime(23277): 	at android.app.servertransaction.ActivityResultItem.execute(ActivityResultItem.java:49)
E/AndroidRuntime(23277): 	at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
E/AndroidRuntime(23277): 	at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
E/AndroidRuntime(23277): 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1816)
E/AndroidRuntime(23277): 	at android.os.Handler.dispatchMessage(Handler.java:106)
E/AndroidRuntime(23277): 	at android.os.Looper.loop(Looper.java:193)
E/AndroidRuntime(23277): 	at android.app.ActivityThread.main(ActivityThread.java:6718)
E/AndroidRuntime(23277): 	at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(23277): 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:491)
E/AndroidRuntime(23277): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
E/AndroidRuntime(23277): Caused by: java.lang.IllegalArgumentException: Invalid column _data
E/AndroidRuntime(23277): 	at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:165)
E/AndroidRuntime(23277): 	at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:135)
E/AndroidRuntime(23277): 	at android.content.ContentProviderProxy.query(ContentProviderNative.java:418)
E/AndroidRuntime(23277): 	at android.content.ContentResolver.query(ContentResolver.java:803)
E/AndroidRuntime(23277): 	at android.content.ContentResolver.query(ContentResolver.java:753)
E/AndroidRuntime(23277): 	at android.content.ContentResolver.query(ContentResolver.java:711)
E/AndroidRuntime(23277): 	at io.github.itzmeanjan.intent.IntentPlugin.uriToFilePath(IntentPlugin.kt:241)
E/AndroidRuntime(23277): 	at io.github.itzmeanjan.intent.IntentPlugin.access$uriToFilePath(IntentPlugin.kt:20)
E/AndroidRuntime(23277): 	at io.github.itzmeanjan.intent.IntentPlugin$onMethodCall$1.onActivityResult(IntentPlugin.kt:58)
E/AndroidRuntime(23277): 	at io.flutter.embedding.engine.FlutterEnginePluginRegistry$FlutterEngineActivityPluginBinding.onActivityResult(FlutterEnginePluginRegistry.java:691)
E/AndroidRuntime(23277): 	at io.flutter.embedding.engine.FlutterEnginePluginRegistry.onActivityResult(FlutterEnginePluginRegistry.java:378)
E/AndroidRuntime(23277): 	at io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.onActivityResult(FlutterActivityAndFragmentDelegate.java:597)
E/AndroidRuntime(23277): 	at io.flutter.embedding.android.FlutterActivity.onActivityResult(FlutterActivity.java:582)
E/AndroidRuntime(23277): 	at android.app.Activity.dispatchActivityResult(Activity.java:7462)
E/AndroidRuntime(23277): 	at android.app.ActivityThread.deliverResults(ActivityThread.java:4391)
E/AndroidRuntime(23277): 	... 11 more
I/Process (23277): Sending signal. PID: 23277 SIG: 9
Lost connection to device.
Exited (sigterm)

flutter doctor

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel beta, 1.18.0-11.1.pre, on Mac OS X 10.15.5 19F96, locale en-IN)
 
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
[✓] Xcode - develop for iOS and macOS (Xcode 11.5)
[✓] Android Studio (version 3.6)
[✓] VS Code (version 1.46.1)
[✓] Connected device (1 available)

• No issues found!

Problem with choosing sim slot before call in dual sim phones

Hello,
I really appreciated this plugin and in fact it helped me a lot. Thank you very much in advance. However, I have problem with choosing sim slot programmatically. Is it possible to choose sim slot to call with? I meant if the phone is available for dual sim, how it could be chosen before the call start?

Regards.

Not Recognizing "audio/*" as a type

Hi,
The plugin is not recognizing intents for opening audio files in relevant applications
It works fine for image/* and video/* type
Here is my code snippet

                final intent = android_intent.Intent()
                  ..setAction(android_action.Action.ACTION_VIEW)
                  ..setData(file.uri)
                  ..setType('audio/*'); //todo
                await intent.startActivity();

Error produced

E/flutter ( 1679): [ERROR:flutter/lib/ui/ui_dart_state.cc(166)] Unhandled Exception: PlatformException(Error, android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW typ=audio/* }, null)

Error Handling Is Needed......

I have tried so many times then I finally got what I wanted. But my app crashed like 20 times. Every time I have to rebuilt it again.
So I think there are issues related to error handling especially NULL pointer error.

How to get result of Action.ACTION_CALL?

how to get result in Flutter from android_intent.Intent()? I have code like below and how to get info when call will be disconnected?

android_intent.Intent()
                      ..setAction(android_action.Action.ACTION_CALL)
                      ..setData(Uri(scheme: "tel", path: 'phone number'))
                      ..startActivity();

The plugins `intent` use a deprecated version of the Android embedding.

i get this message after run flutter upgrade and flutter pub get :

Running "flutter pub get" in mobile_jeanswest_app_android...         ۴٫۲s
The plugins `intent` use a deprecated version of the Android embedding.
To avoid unexpected runtime failures, or future build failures, try to see if these plugins support the Android V2 embedding. Otherwise, consider removing them since a future release of Flutter will remove these deprecated APIs.
If you are plugin author, take a look at the docs for migrating the plugin to the V2 embedding: https://flutter.dev/go/android-plugin-migration.
Process finished with exit code 0

Add support for custom extra types

If you pass boolean or int for other Extras, it will just try to cast them to String which will result in an exception.

Example for openning a calendar's add event page:

Intent()
  ..setAction(Action.ACTION_INSERT)
  ..setData(Uri.parse('content://com.android.calendar/events'))
  ..putExtra("description", dayName)
  ..putExtra('beginTime', time)
  ..putExtra('endTime', time)
  ..putExtra('allDay', true)
  ..startActivityForResult(createChooser: true)
    .catchError((e) => print(e));

Missing Plugin issue

No implementation found for method startActivity on channel intent - error throws

android:authorities wrong

Hi, the plugin hardcodes the plugin authority to io.github.itzmeanjan.intent.fileProvider and it causes a conflict when using 2 apps on the same phone that use the library, here is the error I got

Failure [INSTALL_FAILED_CONFLICTING_PROVIDER: Package couldn't be installed in /data/app/com.blankedOut.projectone-RhGbhs4NKuaKfdXJ62UF5w==: Can't install because provider name io.github.itzmeanjan.intent.fileProvider (in package com.blankedOut.projectone) is already used by com.blankedOut.projecttwo]

You cannot have 2 apps with this library on the same phone, please fix the provider id

how to add putString parameters ?

How to implement the below code with this package?

Bundle mBundle = new Bundle();
mBundle.putString(key, value);
mIntent.putExtras(mBundle);

Can i navigate autostart with your Intent package?

This's the sample code for android.
Can i do this with your package?

`
String manufacturer = android.os.Build.MANUFACTURER;
try {
Intent intent = new Intent();
if ("xiaomi".equalsIgnoreCase(manufacturer)) {
intent.setComponent(new ComponentName("com.miui.securitycenter", "com.miui.permcenter.autostart.AutoStartManagementActivity"));
} else if ("oppo".equalsIgnoreCase(manufacturer)) {
intent.setComponent(new ComponentName("com.coloros.safecenter", "com.coloros.safecenter.permission.startup.StartupAppListActivity"));
} else if ("vivo".equalsIgnoreCase(manufacturer)) {
intent.setComponent(new ComponentName("com.vivo.permissionmanager", "com.vivo.permissionmanager.activity.BgStartUpManagerActivity"));
} else if ("Letv".equalsIgnoreCase(manufacturer)) {
intent.setComponent(new ComponentName("com.letv.android.letvsafe", "com.letv.android.letvsafe.AutobootManageActivity"));
} else if ("Honor".equalsIgnoreCase(manufacturer)) {
intent.setComponent(new ComponentName("com.huawei.systemmanager", "com.huawei.systemmanager.optimize.process.ProtectActivity"));
}

  List<ResolveInfo> list = getPackageManager().queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY);
  if (list.size() > 0) {
            startActivity(intent);
  }

} catch (Exception e) {
e.printStackTrace();
}
`

ACTION_CREATE_DOCUMENT kotlin.KotlinNullPointerException

I am trying to create a file using ACTION_CREATE_DOCUMENT. The intent launch the file manager but once after I save the file, my flutter apps dies to this exception.

Intent()
      ..setAction(Action.ACTION_CREATE_DOCUMENT)
      ..setType("application/pdf")
      ..setData(Uri(path: path))
      ..addCategory(intent_category.Category.CATEGORY_OPENABLE)
      ..putExtra(Extra.EXTRA_TITLE, "path.pdf")
      ..startActivityForResult()
          .catchError((e) => print(e))
          .then((value) => print(value));
E/AndroidRuntime(11603): Caused by: kotlin.KotlinNullPointerException
E/AndroidRuntime(11603): 	at io.github.itzmeanjan.intent.IntentPlugin.uriToFilePath(IntentPlugin.kt:252)
E/AndroidRuntime(11603): 	at io.github.itzmeanjan.intent.IntentPlugin.access$uriToFilePath(IntentPlugin.kt:20)
E/AndroidRuntime(11603): 	at io.github.itzmeanjan.intent.IntentPlugin$onMethodCall$1.onActivityResult(IntentPlugin.kt:58)
E/AndroidRuntime(11603): 	at io.flutter.embedding.engine.FlutterEnginePluginRegistry$FlutterEngineActivityPluginBinding.onActivityResult(FlutterEnginePluginRegistry.java:691)
E/AndroidRuntime(11603): 	at io.flutter.embedding.engine.FlutterEnginePluginRegistry.onActivityResult(FlutterEnginePluginRegistry.java:378)
E/AndroidRuntime(11603): 	at io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.onActivityResult(FlutterActivityAndFragmentDelegate.java:597)
E/AndroidRuntime(11603): 	at io.flutter.embedding.android.FlutterFragment.onActivityResult(FlutterFragment.java:699)
E/AndroidRuntime(11603): 	at io.flutter.embedding.android.FlutterFragmentActivity.onActivityResult(FlutterFragmentActivity.java:510)
E/AndroidRuntime(11603): 	at android.app.Activity.dispatchActivityResult(Activity.java:8393)
E/AndroidRuntime(11603): 	at android.app.ActivityThread.deliverResults(ActivityThread.java:5442

Cannot display specific image in Gallery

Hi! Thanks for a great plugin. I am using

android_intent.Intent() ..setAction(android_action.Action.ACTION_MAIN) ..addCategory(android_category.Category.CATEGORY_APP_GALLERY) ..startActivity().catchError((e) => print(e));

to bring up the Gallery. This works, but what I really want to do is to start the Gallery app with the latest image being displayed. This is what the standard Camera app does, so it should be possible. I have tried some putExtra and addFlag but they seem to be ignored.

Any idea how to accomplish this?

No app functionality enabled

Thank you for creating great features.
Unfortunately, there is one problem.

When you install several apps created with this function on your mobile phone,
There is a problem that the function does not work and Google Play update does not work.

I found this symptom in the phone dialing feature.

Calling a Number : #

latest version error BuildConfig.java:12: error: annotations are not supported in -source 1.3 @Deprecated

C:\Users\kotai\AndroidStudioProjects\barcode_app\build\intent\generated\source\buildConfig\debug\io\github\itzmeanjan\intent\BuildConfig.java:12: error: annotations are not supported in -source 1.3
@deprecated
^
(use -source 5 or higher to enable annotations)
1 error
3 warnings

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':intent:compileDebugJavaWithJavac'.

Compilation failed; see the compiler error output for details.

How can I make intent for share a pdf file to app, for example whatsapp, printter app and email?

I try this but not work, please help me :D

For an App:

Intent()
        ..setAction(Action.ACTION_SEND)
        ..setData(Uri.parse('package:com.whatsapp'))
        ..putExtra(Extra.EXTRA_STREAM, file.path)
        ..startActivity().catchError((e) => print(e));

For an email:

Intent()
      ..setAction(Action.ACTION_SENDTO)
      ..setData(Uri(scheme: 'mailto'))
      ..putExtra(Extra.EXTRA_SUBJECT, 'Subject')
      ..putExtra(Extra.EXTRA_STREAM, file.path)
      ..startActivity().catchError((e) => print(e));

[help needed] Hot to open Advanced Download Manager with argument

Hi, thanks for the package .

How can I write the bellow intent. I have tried couple of ways but it did work with me. I got the code from ADM people but I don't know a lot of android.

I want to open ADM download editor in my app and pass in link, name and headers. Is it possible to do it with this package? if yes then how?
please help

// ------ create
Intent intent = new Intent("android.intent.action.MAIN");
intent.setClassName("com.dv.adm", "com.dv.adm.AEditor");

// ------ 1 --- single addition with Editor opening
intent.putExtra("android.intent.extra.TEXT", "htt_p://example.com/path/name.ext");
// optional
intent.putExtra("com.android.extra.filename", "name.ext");

// ------ 2 --- single and batch addition without Editor opening
intent.putExtra("com.dv.get.ACTION_LIST_ADD", "htt_p://example.com/path/name.ext"); // or "url1<line>url2...", or "url1<info>name_ext1<line>..."
// optional
intent.putExtra("com.dv.get.ACTION_LIST_PATH", "sdcard/path/folder"); // destination directory (default "Settings - Downloading - Folder for files")
intent.putExtra("com.dv.get.ACTION_LIST_OPEN", true)); // opening a activity with the list of downloads (default false)



// ------ send
try {
startActivity(intent);
} catch (ActivityNotFoundException e) {
Log.w("my_app", "not found");
}



// ------ HTTP Headers
// ------ unique for single and same for batch
// ------ 1 ---
intent.putExtra("Cookie", "cookie1=value; cookie2=value;");
intent.putExtra("User-Agent", "Mozilla compatible/1.0");
intent.putExtra("Authorization", "(Access Token)");
intent.putExtra("Referer", "htt_p://example.com/specific-path");
// ------ 2 ---
String[] headers = new String[] { "Cookie", "cookie1=value; cookie2=value;", //
"User-Agent", "Mozilla compatible/1.0", //
"Authorization", "(Access Token)", //
"Referer", "htt_p://example.com/specific-path", };
intent.putExtra("headers", headers);
// ------ 3 ---
Bundle bundle = new Bundle();
bundle.putString("Cookie", "cookie1=value; cookie2=value;");
bundle.putString("User-Agent", "Mozilla compatible/1.0");
bundle.putString("Authorization", "(Access Token)");
bundle.putString("Referer", "htt_p://example.com/specific-path");
intent.putExtra("android.media.intent.extra.HTTP_HEADERS", bundle);



// ------ global Intents
sendBroadcast(new Intent("com.dv.get.ACTION_START_ALL"));
sendBroadcast(new Intent("com.dv.get.ACTION_STOP_ALL"));

Crash on second intent

I am starting a camera with startActivityForResult. The first time I get the path to the taken image back as it should. When I use the intent again, the app crashes without any error in the flutter console. But I get some Logcat output (from Android Studio).

Here the code:

        floatingActionButton: FloatingActionButton(
          child: Icon(Icons.camera_alt),
          onPressed: () => android_intent.Intent()
            ..setAction(android_action.Action.ACTION_IMAGE_CAPTURE)
            ..startActivityForResult()
            .then(
                  (data) {
                      print(data[0]);
                  },
              onError: (e) =>
                  print(e.toString()),
            )
        ),

And here the error message in Logcat:

020-02-06 11:39:12.549 21972-21972/com.example.vivo_mobile_testing_app E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.example.vivo_mobile_testing_app, PID: 21972
    java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=998, result=-1, data=null} to activity {com.example.vivo_mobile_testing_app/com.example.vivo_mobile_testing_app.MainActivity}: java.lang.IllegalStateException: Reply already submitted
        at android.app.ActivityThread.deliverResults(ActivityThread.java:4506)
        at android.app.ActivityThread.handleSendResult(ActivityThread.java:4548)
        at android.app.servertransaction.ActivityResultItem.execute(ActivityResultItem.java:49)
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1916)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:193)
        at android.app.ActivityThread.main(ActivityThread.java:6898)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:537)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
     Caused by: java.lang.IllegalStateException: Reply already submitted
        at io.flutter.embedding.engine.dart.DartMessenger$Reply.reply(DartMessenger.java:148)
        at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler$1.success(MethodChannel.java:234)
        at io.github.itzmeanjan.intent.IntentPlugin$onMethodCall$5.sendDocument(IntentPlugin.kt:132)
        at io.github.itzmeanjan.intent.IntentPlugin$onMethodCall$1.onActivityResult(IntentPlugin.kt:68)
        at io.flutter.embedding.engine.FlutterEnginePluginRegistry$FlutterEngineActivityPluginBinding.onActivityResult(FlutterEnginePluginRegistry.java:634)
        at io.flutter.embedding.engine.FlutterEnginePluginRegistry.onActivityResult(FlutterEnginePluginRegistry.java:367)
        at io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.onActivityResult(FlutterActivityAndFragmentDelegate.java:546)
        at io.flutter.embedding.android.FlutterActivity.onActivityResult(FlutterActivity.java:594)
        at android.app.Activity.dispatchActivityResult(Activity.java:7476)
        at android.app.ActivityThread.deliverResults(ActivityThread.java:4499)
        at android.app.ActivityThread.handleSendResult(ActivityThread.java:4548) 
        at android.app.servertransaction.ActivityResultItem.execute(ActivityResultItem.java:49) 
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108) 
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1916) 
        at android.os.Handler.dispatchMessage(Handler.java:106) 
        at android.os.Looper.loop(Looper.java:193) 
        at android.app.ActivityThread.main(ActivityThread.java:6898) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:537) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858) 

The expected behaviour for me would have been that it works on the second time, too.

Getting NullPointer exception startActivityForResult

I am trying the following example:

android_intent.Intent()
      ..setAction('ACTION_PICK')
      ..setData(Uri.parse('content://contacts'))
      ..setType("vnd.android.cursor.dir/phone_v2")
      ..startActivityForResult().then((data) {
        print(data);
      }, onError: (e) => print(e));

It results in this exception:
D/AndroidRuntime(11988): Shutting down VM E/AndroidRuntime(11988): FATAL EXCEPTION: main E/AndroidRuntime(11988): Process: com.example.communication_test, PID: 11988 E/AndroidRuntime(11988): java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=999, result=0, data=null} to activity {com.example.communication_test/com.example.communication_test.MainActivity}: java.lang.IllegalStateException: Reply already submitted E/AndroidRuntime(11988): at android.app.ActivityThread.deliverResults(ActivityThread.java:3574) E/AndroidRuntime(11988): at android.app.ActivityThread.handleSendResult(ActivityThread.java:3617) E/AndroidRuntime(11988): at android.app.ActivityThread.access$1300(ActivityThread.java:151) E/AndroidRuntime(11988): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1352) E/AndroidRuntime(11988): at android.os.Handler.dispatchMessage(Handler.java:102) E/AndroidRuntime(11988): at android.os.Looper.loop(Looper.java:135) E/AndroidRuntime(11988): at android.app.ActivityThread.main(ActivityThread.java:5254) E/AndroidRuntime(11988): at java.lang.reflect.Method.invoke(Native Method) E/AndroidRuntime(11988): at java.lang.reflect.Method.invoke(Method.java:372) E/AndroidRuntime(11988): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903) E/AndroidRuntime(11988): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698) E/AndroidRuntime(11988): Caused by: java.lang.IllegalStateException: Reply already submitted E/AndroidRuntime(11988): at io.flutter.embedding.engine.dart.DartMessenger$Reply.reply(DartMessenger.java:155) E/AndroidRuntime(11988): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler$1.success(MethodChannel.java:238) E/AndroidRuntime(11988): at io.github.itzmeanjan.intent.IntentPlugin$onMethodCall$5.sendDocument(IntentPlugin.kt:180) E/AndroidRuntime(11988): at io.github.itzmeanjan.intent.IntentPlugin$onMethodCall$1.onActivityResult(IntentPlugin.kt:63) E/AndroidRuntime(11988): at io.flutter.embedding.engine.FlutterEngineConnectionRegistry$FlutterEngineActivityPluginBinding.onActivityResult(FlutterEngineConnectionRegistry.java:739) E/AndroidRuntime(11988): at io.flutter.embedding.engine.FlutterEngineConnectionRegistry.onActivityResult(FlutterEngineConnectionRegistry.java:426) E/AndroidRuntime(11988): at io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.onActivityResult(FlutterActivityAndFragmentDelegate.java:668) E/AndroidRuntime(11988): at io.flutter.embedding.android.FlutterActivity.onActivityResult(FlutterActivity.java:618) E/AndroidRuntime(11988): at android.app.Activity.dispatchActivityResult(Activity.java:6192) E/AndroidRuntime(11988): at android.app.ActivityThread.deliverResults(ActivityThread.java:3570) E/AndroidRuntime(11988): ... 10 more

Can you tell me what i am doing wrong? I would like to receive some data back from an app which i launch with an intent.

Tank you!

how to send parameters ?

Hi
How can I send parameters like this? ( this is android native )

Intent intent = new Intent("com.bpmellat.merchant");
intent.putExtra("PaymentData","{'param1':'value'}"); 
startActivityForResult(intent); 

thanks in advance

error in sharing to story Instagram

Due to the Sharing to Stories in Instagram, I got this error:

PlatformException(Error, android.content.ActivityNotFoundException: No Activity found to handle Intent { act=com.instagram.share.ADD_TO_STORY typ=png flg=0x1 (has extras) }, null)

Here is my example code:

Intent()
          ..setAction("com.instagram.share.ADD_TO_STORY")
          ..setType("png")
          ..setData(Uri.parse(exportedFile.path))
          ..addFlag(1) // FLAG_GRANT_READ_URI_PERMISSION = 1
          ..putExtra("content_url", "http://vocofit.ir")
          ..startActivity().catchError((e) => print(e));

Is there any problem in my code?

Method putParcelableArrayListExtra is missing

Since this plugin supports ACTION_SEND_MULTIPLE action, it should be able to provide full functionality.
There should be a way to share multiple objects like in Java/Kotlin:
`
ArrayList imageUris = new ArrayList();
imageUris.add(imageUri1); // Add your image URIs here
imageUris.add(imageUri2);

Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND_MULTIPLE);
shareIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, imageUris);
shareIntent.setType("image/*");
startActivity(Intent.createChooser(shareIntent, "Share images to.."));
`
android developers documentation

how to open contact detail page

I want following code via this plugging can someone help how can i do??

Intent intent = new Intent(Intent.ACTION_VIEW);
Uri uri = Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_URI,
String.valueOf(contactID));
intent.setData(uri);
context.startActivity(intent);

[Question] Permissions

Hi 👋🏼
I'm new with the intent things and I don't know if it's possible to open the permissions detail screen of an app and focus the permission that I'm asking for a second.

Screenshot of how other apps redirect me to what I'm referring.
image

Also this is code is throwing me
Exception has occurred. PlatformException (PlatformException(Error, android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.SHOW_APP_INFO pkg=com.my_package_app_name }, null))

I copied the code that is at the readme and check that the package name is correct using also other library and reviewing the build.gradle

  android_intent.Intent()
                        ..setAction(android_action.Action.ACTION_SHOW_APP_INFO)
                        ..setPackage("com.my_package_app_name")
                        ..startActivity().catchError((e) => print(e));

How to Intent to AppInfo Screen with package name?

157917843_870597266847172_6230172749235747415_n
Like This Screen (AppInfo)

I try this but not work.
I think something is missing on my code.
Can u light me to carry on?
openAppInfo(String package) { android_intent.Intent() ..setAction(android_action.Action.ACTION_SHOW_APP_INFO) ..putExtra(android_extra.Extra.EXTRA_PACKAGE_NAME, package) ..startActivity().catchError((e) => print(e)); }

Clear thing is this code i want to use in flutter.
Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS); Uri uri = Uri.fromParts("package", getPackageName(), null); intent.setData(uri); startActivity(intent);

Error Snippet
E/MethodChannel#intent( 2449): Failed to handle method call E/MethodChannel#intent( 2449): kotlin.KotlinNullPointerException E/MethodChannel#intent( 2449): at io.github.itzmeanjan.intent.IntentPlugin.onMethodCall(IntentPlugin.kt:118) E/MethodChannel#intent( 2449): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:233) E/MethodChannel#intent( 2449): at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:85) E/MethodChannel#intent( 2449): at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:818) E/MethodChannel#intent( 2449): at android.os.MessageQueue.nativePollOnce(Native Method) E/MethodChannel#intent( 2449): at android.os.MessageQueue.next(MessageQueue.java:335) E/MethodChannel#intent( 2449): at android.os.Looper.loop(Looper.java:193) E/MethodChannel#intent( 2449): at android.app.ActivityThread.main(ActivityThread.java:7876) E/MethodChannel#intent( 2449): at java.lang.reflect.Method.invoke(Native Method) E/MethodChannel#intent( 2449): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:656) E/MethodChannel#intent( 2449): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:967) I/flutter ( 2449): PlatformException(error, null, null, kotlin.KotlinNullPointerException I/flutter ( 2449): at io.github.itzmeanjan.intent.IntentPlugin.onMethodCall(IntentPlugin.kt:118) I/flutter ( 2449): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:233) I/flutter ( 2449): at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:85) I/flutter ( 2449): at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:818) I/flutter ( 2449): at android.os.MessageQueue.nativePollOnce(Native Method) I/flutter ( 2449): at android.os.MessageQueue.next(MessageQueue.java:335) I/flutter ( 2449): at android.os.Looper.loop(Looper.java:193) I/flutter ( 2449): at android.app.ActivityThread.main(ActivityThread.java:7876) I/flutter ( 2449): at java.lang.reflect.Method.invoke(Native Method) I/flutter ( 2449): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:656) I/flutter ( 2449): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:967) I/flutter ( 2449): )

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.