I want to open the Deezer Android Application from URI using Android Intent.
My code is:
try {
uri = "deezer://track/"+track_id;
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));
activity.startActivity(intent);
} catch (Exception e) {
uri = "http://www.deezer.com/track/"+track_id;
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));
activity.startActivity(intent);
}
However, the URI "deezer://track/track_id is never detected by Deezer and doesn't work.
Anybody knows the correct URI syntax for that ?
(I use the same code for Spotify and it works with the URI: spotify:track:track_id)
If you really want to use the deezer:// scheme, you can use the following uri :
uri = "deezer://www.deezer.com/track/"+track_id;
Edit :
You can also use some query parameters to add behavior to your link, for instance the following uri : deezer://www.deezer.com/album/10596327?autoplay=true&start_index=13 will open the deezer app on the album's page immediately and will start playing with the 14th track (0 based index).
Related
This question already has answers here:
How to open the Google Play Store directly from my Android application?
(26 answers)
Closed 3 years ago.
I've recently started creating an app for Android.
I want to add "Rate us" button that sends to the app in Google play store.
How to get the URL, and what is the code to do that ?
You can get playstore URL using package name of APP,
Uri uri = Uri.parse("market://details?id=" + context.getPackageName());
or
Uri uri = Uri.parse("http://play.google.com/store/apps/details?id=" + context.getPackageName())
you can use this way:
Uri uri = Uri.parse("market://details?id=" + context.getPackageName());
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY |
Intent.FLAG_ACTIVITY_NEW_DOCUMENT |
Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
try {
startActivity(intent);
} catch (ActivityNotFoundException e) {
startActivity(new Intent(Intent.ACTION_VIEW,
Uri.parse("http://play.google.com/store/apps/details?id=" + context.getPackageName())));
}
Hope it will help!!
First of all, you should upload your App to the Google Play Store. Then, you should go to the profile of your app in store and choose "Copy URL", your url-adress may looks like:
https://play.google.com/store/apps/details?id=<app_name>
To get the URL in App and use it, you should create method with next code-line:
Uri appUrl = Uri.parse("http://play.google.com/store/apps/details?id=" + context.getPackageName() + "")
Final result of code to do that here:
startActivity(new Intent(Intent.ACTION_VIEW,
Uri.parse("http://play.google.com/store/apps/details?id=" +getPackageName())));
Main topic: https://developer.android.com/distribute/marketing-tools/linking-to-google-play
I am working on a demo to share multiple photos on different social platforms. I was able to post a single picture using the code on Instagram but i am not sure how to post multiple images on it. I am not sure even if Instagram provides such functionality.
Try like this
ArrayList<Uri> images = new ArrayList<Uri>();
Files[] imagesFiles; //your imagesFile
for(String path : imagesFiles) {
File file = new File(path);
Uri uri = Uri.fromFile(file);
files.add(uri);
}
Intent intent = new Intent();
intent.setAction(Intent.ACTION_SEND_MULTIPLE);
intent.putExtra(Intent.EXTRA_SUBJECT, images);
intent.setType("image/jpeg");
You'll need to use Intent.ACTION_SEND_MULTIPLE.
Intent intent = new Intent();
intent.setAction(Intent.ACTION_SEND_MULTIPLE);
intent.putExtra(Intent.EXTRA_SUBJECT, "Here are some files.");
intent.setType("image/jpeg"); /* This example is sharing jpeg images. */
intent.setPackage("com.instagram.android");
ArrayList<Uri> files = new ArrayList<Uri>();
for(String path : filesToSend /* List of the files you want to send */) {
File file = new File(path);
Uri uri = Uri.fromFile(file);
files.add(uri);
}
intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, files);
startActivity(intent);
This could definitely be simplified but I left some lines in so you can break down each step that is needed.
NOTE: Starting in API 24, sharing file URIs will cause a FileUriExposedException. You can either switch your compileSdkVersion to 23 or lower or you can use content URIs with a FileProvider.
***Facebook deprecated xmpp api.
Is there a way to open an intent (or pass data to fb) to send chat message on android device?
Facebook & Messenger apps installed on the device.
Thanks :-)
You need to pass uri to the intent
Here 100005727832736 is the user id of the person who you want to
message to
Uri uri = Uri.parse("fb-messenger://user/100005727832736");
Here is my sample code
Uri uri = Uri.parse("fb-messenger://user/100005727832736");
Intent toMessenger= new Intent(Intent.ACTION_VIEW, uri);
try {
startActivity(toMessenger);
}
catch (android.content.ActivityNotFoundException ex)
{
Toast.makeText(context, "Please Install Facebook Messenger", Toast.LENGTH_LONG).show();
}
}
This is what worked for me and i haven not tested this for some time now.
To launch facebook app let urlString = "fb://page/your_fb_page_id"
To launch facebook messenger let urlString = "fb-messenger://user/your_fb_page_id"
FB page id is usually numeric. To get it, goto Find My FB ID input your profile url, something like www.facebook.com/edgedevstudio then click "Find Numberic ID".
Voila, you now have your fb numeric id. replace "your_fb_page_id" with the generated Numeric ID
val intent = Intent(Intent.ACTION_VIEW, Uri.parse(urlString))
if (intent.resolveActivity(packageManager) != null) //check if app is available to handle the implicit intent
startActivity(intent)
I am using a URI that i pass to a MediaPlayer on android like this:
mediaPlayer.setDataSource(context, Uri.parse(<uri>));
When I get it using Intent.createChooser, it plays once then trying to make it play it again result in java.io.IOException: setDataSource failed.: status=0x80000000.
When i pass the URI as a string directly, it results in java.io.IOException: setDataSource failed.: status=0x80000000, despite the URI outputed by the selector being always the same.
The uri look like this: "content://com.android.providers.media.documents/document/audio%3A21739".
Can someone please enlighten on why does this happen?
Turns out android required some weird permissions shenanigans, the solutions was using a different opening coupled with using some sort of permission requirement that somehow output the same uri, but with a persistent access:
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
intent.setType("*/*");
intent.addCategory(Intent.CATEGORY_OPENABLE);
startActivityForResult(Intent.createChooser(intent, "Select file to add"), ADD_2);
In onActivityResult:
if (resultCode == RESULT_OK) {
Uri uri = data.getData();
final int takeFlags = data.getFlags() & Intent.FLAG_GRANT_READ_URI_PERMISSION;
getContentResolver().takePersistableUriPermission(uri, takeFlags);
Log.d(TAG, "Added track uri: " + uri);
playlist.add(uri.toString());
adapter.notifyDataSetChanged();
}
I'm trying to start a Skype intent from my Android App, passing a phone number. So far, thanks to other people who ad similiar needs here on stackoverflow, I've managed to start skype, but still I can't pass the phone number. This is the code I'm using:
Intent sky = new Intent("android.intent.action.CALL_PRIVILEGED");
sky.setClassName("com.skype.raider",
"com.skype.raider.Main");
sky.setData(Uri.parse("tel:" + number));
Log.d("UTILS", "tel:" + number);
ctx.startActivity(sky);
What's happening is that skype starts, but gives me a toast saying that the number is not valid, and suggests me to add the international prefix.
The Log.d gives me tel:+39........ (the number works, I'm using it also for
public static void call(String number, Context ctx) {
try {
Intent callIntent = new Intent(Intent.ACTION_CALL);
callIntent.setData(Uri.parse("tel:" + number));
ctx.startActivity(callIntent);
} catch (ActivityNotFoundException e) {
Log.e("helloandroid dialing example", "Call failed", e);
}
}
In fact, when I go to the Skype's view for calling, I see it's been composed +0
So what it seems to me is that I'm passing the phone number in the wrong way, or to the wrong Activity....any help would be very appreciated!
In the meantime, I just want to say that StackOverflow simply rocks.
See this answer: https://stackoverflow.com/a/8844526/819355
Jeff suggests using a skype:<user name> instead of tel:<phone number>
After some studing of the skype apk with apktool, as suggested in that answer, I came up with this code, for me it's working:
public static void skype(String number, Context ctx) {
try {
//Intent sky = new Intent("android.intent.action.CALL_PRIVILEGED");
//the above line tries to create an intent for which the skype app doesn't supply public api
Intent sky = new Intent("android.intent.action.VIEW");
sky.setData(Uri.parse("skype:" + number));
Log.d("UTILS", "tel:" + number);
ctx.startActivity(sky);
} catch (ActivityNotFoundException e) {
Log.e("SKYPE CALL", "Skype failed", e);
}
}
Refer to Skype developer: Skype URI tutorial: Android apps
Also remember to add "?call" in your url. E.g
intent.setData(Uri.parse("skype:" + phoneNumber + "?call"));
Without it, Skype may not dial the number.
You should not include a specific class when calling an external app. Let the user decide of the application he/she wants to use. That's the way android has been designed and it's a better solution than obliging people to use a soft (moreover quite a slow, closed and inconvenient app to my mind).
In other words, just use the Uri, that's the job of skype of declaring its ability to capture such intents.
Refer this skype doc link Skype URI tutorial: Android apps
First need to check skype is installed or not using
/**
* Determine whether the Skype for Android client is installed on this device.
*/
public boolean isSkypeClientInstalled(Context myContext) {
PackageManager myPackageMgr = myContext.getPackageManager();
try {
myPackageMgr.getPackageInfo("com.skype.raider", PackageManager.GET_ACTIVITIES);
}
catch (PackageManager.NameNotFoundException e) {
return (false);
}
return (true);
}
initiate skype uri using
/**
* Initiate the actions encoded in the specified URI.
*/
public void initiateSkypeUri(Context myContext, String mySkypeUri) {
// Make sure the Skype for Android client is installed.
if (!isSkypeClientInstalled(myContext)) {
goToMarket(myContext);
return;
}
// Create the Intent from our Skype URI.
Uri skypeUri = Uri.parse(mySkypeUri);
Intent myIntent = new Intent(Intent.ACTION_VIEW, skypeUri);
// Restrict the Intent to being handled by the Skype for Android client only.
myIntent.setComponent(new ComponentName("com.skype.raider", "com.skype.raider.Main"));
myIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
// Initiate the Intent. It should never fail because you've already established the
// presence of its handler (although there is an extremely minute window where that
// handler can go away).
myContext.startActivity(myIntent);
return;
}
if Skype is not installed then redirect to market place using
/**
* Install the Skype client through the market: URI scheme.
*/
public void goToMarket(Context myContext) {
Uri marketUri = Uri.parse("market://details?id=com.skype.raider");
Intent myIntent = new Intent(Intent.ACTION_VIEW, marketUri);
myIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
myContext.startActivity(myIntent);
return;
}