So I am trying to make my app auto-start So to do this i have to redirect the user to the auto start screen of the devices. I tried calling intent similar as we get the battery detail app in flutter but it's not working, how to make app autostart any guidance will be helpful.github issue
what I am looking for an alternate way of using
this intent to open auto-start screen in oppo
Intent intent = new Intent();
intent.setClassName("com.coloros.safecenter",
"com.coloros.safecenter.startupapp.StartupAppListActivity");
startActivity(intent);
this is for Xiaomi
Intent intent = new Intent();
intent.setComponent(new ComponentName("com.miui.securitycenter",
"com.miui.permcenter.autostart.AutoStartManagementActivity"));
startActivity(intent)
this intent in flutter. I already looked into flutter intent
I got your question. You can try the following for Xiaomi devices
static const platform = const MethodChannel('com.myapp/intent');
void openAutoStartSettings() async {
await platform.invokeMethod('com.miui.permcenter.autostart.AutoStartManagementActivity');
}
For other manufacturers, please check this post https://tutel.me/c/programming/questions/48166206/how+to+start+power+manager+of+all+android+manufactures+to+enable+background+and+push+notification
I'm not sure what you are asking but to start an app from a flutter app you can use this package:
https://pub.dev/packages/flutter_appavailability
here an exemple to open the mailBox app
try{
AppAvailability.launchApp(Platform.isIOS ? "message://" : "com.google.android.gm").then((_) {
print("App Email launched!");
}).catchError((err) {
print(err);
});
} catch(e) {
print(e);
}
You can use android_intent library for launching external app. Documentation has some sample codes.
You may use sample code below.
var map={"AuthParams":authParam};
var intent=AndroidIntent(package:"in.app",arguments: map,componentName: "in.app.ui.splash.SplashActivity",/*action: "action_view"*/);
await intent.launch();
Related
I have added a share app button and link to my app made in android studio but I'm not sure if this is the way it should work as I have checked other apps' share options and they tend to give the user an option on where exactly they'd like to share their application, while my link sends the user straight to the app page. I found this method on another thread made on this website but I'm not sure if it works properly as I haven't published my app yet. Can someone verify if this is the most popular method to share apps and if not can someone redirect me to where I can find the best solution for a share app option.
segment of my MainActivity.java code regarding the share method:
#Override
public boolean onNavigationItemSelected(#NonNull MenuItem item) {
switch (item.getItemId()) {
case R.id.nav_share:
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://play.google.com/store/apps/details?id=com.mydomain.tapp"));
startActivity(intent);
break;
}
drawerLayout.closeDrawer(GravityCompat.START);
return true;
}
You are using the wrong Intent Action for your requirement. Your requirement is to share your app's PlayStore link with another person. So, you have to use ACTION_SEND.
ACTION_VIEW is used to display the data to the user.
ACTION_SEND is used to deliver some data to someone else.
For example,
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_SUBJECT, "Sharing URL");
intent.putExtra(Intent.EXTRA_TEXT, "http://play.google.com/store/apps/details?id=com.mydomain.tapp");
startActivity(intent);
I am developing a video player app and I want my app to Prompt for the permission to be the default Video Player to be the default handler of video play.
I know it has to be something like the default handler:
Intent setSmsAppIntent =
new Intent(Telephony.Sms.Intents.ACTION_CHANGE_DEFAULT);
setSmsAppIntent.putExtra(Telephony.Sms.Intents.EXTRA_PACKAGE_NAME,
getPackageName());
startActivityForResult(setSmsAppIntent, your-result-code);`
source: Android Docs
But I don't know the Action I have to give to the Intent as action. Can someone please help me?
Thanks in advance.
It's not possible, developers can't call intent to change default Video player only users can do that on their device. Its only possible for SMS service.
However, for video player you can register app for video player in AndroidManifest.xml and call the function which opens settings to change default apps using the following code:
Intent intent = new Intent(Settings.ACTION_MANAGE_DEFAULT_APPS_SETTINGS);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
I'm looking for a way to open default email application on Android, but without using it to send a message. I know I can do this using mailto:// or intent params, but this automatically opens new message screen. What I want to to archieve, is just opening the app itself.
So far, I have tried
override fun startEmailApplication() {
val intent = Intent(Intent.ACTION_MAIN)
intent.addCategory(Intent.CATEGORY_APP_EMAIL)
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
startActivity(intent)
}
But every time I get
android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW cat=[android.intent.category.APP_EMAIL] flg=0x10000000 }
Altrough an email app (AquaMail, Outlook) is installed.
I would use a combinaison a little things.
Detect the responding packages for a given Intent:
Intent intent = new Intent(Intent.ACTION_SENDTO);
intent.setType("text/plain");
List<ResolveInfo> resolveInfos = getPackageManager().queryIntentActivities(intent, 0);
boolean canResolve = resolveInfos.size() > 0;
This will list the available packages to respond to such Intent. Using queryIntentActivities() allows me to retrieve ResolveInfo which exposes more information about the app.
Select the first one and open it using its packageName:
if (resolveInfos.size() > 0) {
startActivity(getPackageManager().getLaunchIntentForPackage(resolveInfos.get(0).resolvePackageName))
}
You also won't have the ActivityNotFoundException because we check before hand that something will respond to our Intent. Feel free to handle the failing case in a else.
You can do the following:
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_APP_EMAIL);
getActivity().startActivity(intent);
My application has a button to start default sms activity and
it worked perfectly fine all android version except new one, Android 4.4(kitkat)
Here is the code:
public void onClick(View arg0) {
Intent smsIntent = new Intent(Intent.ACTION_VIEW);
smsIntent.setType("vnd.android-dir/mms-sms");
smsIntent.putExtra("address", member.getPhoneNumber().trim());
context.startActivity(smsIntent);
}
And I get error messages
11-08 02:08:32.815: E/AndroidRuntime(14733): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW typ=vnd.android-dir/mms-sms (has extras) }
I know that google made some changes on how the default sms app handles sms intents.
but my app is not a sms app but it only has function to start default sms app with recipient number. so please help.
To start the SMS app with number populated use action ACTION_SENDTO:
Intent intent = new Intent(Intent.ACTION_SENDTO);
intent.setData(Uri.parse("smsto:" + Uri.encode(phoneNumber)));
startActivity(intent);
This will work on Android 4.4. It should also work on earlier versions of Android however as the APIs were never public the behavior might vary. If you didn't have issues with your prior method I would probably just stick to that pre-4.4 and use ACTION_SENDTO for 4.4+.
to start the sms app without insert the number, you should delete setType
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse("sms:"));
intent.putExtra("sms_body", "smsMsgVar");
startActivity(intent);
The issue happened when you are testing with Emulator,
Please test with the actual device.
In Kotlin this code works:
val defaultSmsPackageName = Telephony.Sms.getDefaultSmsPackage(activity)
val sendIntent = Intent(Intent.ACTION_SEND)
sendIntent.type = "text/plain"
sendIntent.putExtra("address", "sms:"+contactNumber)
sendIntent.putExtra(Intent.EXTRA_TEXT, getString(R.string.share_msg_body))
Timber.e("defaultSmsPackageName: "+defaultSmsPackageName)
if (defaultSmsPackageName != null){ //Can be null in case that there is no default, then the user would be able to choose any app that support this intent.
sendIntent.setPackage(defaultSmsPackageName)
activity!!.startActivity(sendIntent)
}
I am able to intent to the youtube app to view a video easily enough, but how about getting to a profile / channel?
public void YouTube(String id) {
// Play Youtube Video
Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse("vnd.youtube:"+id));
mContext.startActivity(i);
}
I.. just don't know where to really begin here? Is there a specific Uri to parse? I've tried scouring the internet of course and I'm coming up dry for answers. Is it even possible in the first place?
Thanks guys!
By doing the following ,one can launch Youtube App to display channel directly
Intent intent=null;
try {
intent =new Intent(Intent.ACTION_VIEW);
intent.setPackage("com.google.android.youtube");
intent.setData(Uri.parse(url));
startActivity(intent);
} catch (ActivityNotFoundException e) {
intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(url));
startActivity(intent);
}
And in order to display channel,keep in mind to give url in format http://www.youtube.com/user/channelName
As of now, there is no specific URI scheme for channels that would trigger the YouTube application directly. The vnd.youtube scheme is defined only for the activity that plays a single video. So, you have to specify the canonical YouTube URL for the channel page, and typically let the user pass through the application chooser dialog - assuming that the device has the YouTube application installed, the dialog would display at least two entries, the second being for the browser.