Hi i am creating a simple game and i want yo know how to launch Play Store in ligbdx when someone would like to rate my game.
Please help!
Thanks
You have two options :
Either open directly by using complete URL (generic for all platform)
Gdx.net.openURI("https://play.google.com/store/apps/details?id=com.xyz.abc");
Use interfacing and implement platform specific APIs.
eg. like for Android
public void rate(){
Intent rateIntent = new Intent(Intent.ACTION_VIEW,Uri.parse("https://play.google.com/store/apps/details?id=com.xyz.abc"));
//or
//Intent rateIntent = new Intent(Intent.ACTION_VIEW,Uri.parse("https://play.google.com/store/apps/details?id="+getPackageName()));
startActivity(rateIntent);
}
It prompt a choose dialog, having browser and Playstore app (If PlayStore installed in device) option. choose PlayStore.
EDIT
try {
Intent viewIntent = new Intent(Intent.ACTION_VIEW,Uri.parse("market://details?id=" + getPackageName()));
startActivity(viewIntent);
}catch (android.content.ActivityNotFoundException anfe){
String url="https://play.google.com/store/apps/details?id="+getPackageName();
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
if (intent.resolveActivity(getPackageManager())!=null) {
startActivity(intent);
}
}
I want to open a page in fb app using a deep link (on.fb.me/xxx) but it opens in the web browser, is there a way I can do this? or Am I forced to use the usual fb url (fb://xxx).
the code I'm using right now
final Uri uri = Uri.parse("http://on.fb.me/xxx");
final Intent facebookIntent = new Intent(Intent.ACTION_VIEW, uri);
facebookIntent.setPackage("com.facebook.katana");
try {
startActivity(facebookIntent);
} catch (ActivityNotFoundException e) {
startActivity(new Intent(Intent.ACTION_VIEW, uri));
}
I have the same issue with Instagram and Twitter with links like "bit.ly/xxx"
I am opening a youtube video from my app, similar with this answer: https://stackoverflow.com/a/12439378/379865
I was wondering if it's possible to open the video at a specified time, so for instance have video running from 30 seconds at start, not from the beginning.
YouTube have a great way of indicating time in their URL for the videos.
So let's say a url of a video is
https://www.youtube.com/watch?v=Z149x12sXsw
You can reference the same URL with it playing automatically 30
seconds in by putting &t=0m30s at the end.
When you open the video, pass in the new url with the new
extension. It should look something like
https://www.youtube.com/watch?v=Z149x12sXsw&t=0m30s
The Intent will look something like startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.youtube.com/watch?v=Z149x12sXs" + time))); where String time = "&t=0m30s";
Edit: Expansion for YouTube App.
public static void watchYoutubeVideo(String id, String time){
Intent appIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("vnd.youtube:" + id + time));
Intent webIntent = new Intent(Intent.ACTION_VIEW,
Uri.parse("https://www.youtube.com/watch?v=" + id + time));
try {
startActivity(appIntent);
} catch (ActivityNotFoundException ex) {
startActivity(webIntent);
}
}
Using another answer from that question. The same logic can be applied to any intent just add the Time string to the URI like shown above regardless of intention.
Try Opening url with url something similar to this
https://www.youtube.com/watch?v=u0IU8uQniX8&t=2m35s
where t= time in minutes and seconds
t=2m35s
try {
ourBrowser.loadUrl("http://google.com");
} catch (Exception e) {
e.printStackTrace();
}
this code is ok i know but how can i search any site without using Http or www ... like other android browser's . example sometime we type Hello and Google give us all hello worlds with link's....... i m new in android world so please developer's help me out....?
i m also tried this method = ourBrowser.loadUrl("http://google.com"+url);
https://www.google.cz/search?q=search+term
is the thing you want or use it as intent:
Uri uri = Uri.parse("http://www.google.com/#q=fish");
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(intent);
Maybe it's what you need ?
public void launchUrl(String URL){
Intent browserIntent = new Intent(Intent.ACTION_VIEW,
Uri.parse("https://www.google.fr/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q="+URL));
startActivity(browserIntent);
}
And you will call it with
launchUrl("MysearchExample");
I have made an application now i want to implement Rate Us feature in it. so for that i have added this code in my app
i = new Intent(Intent.ACTION_VIEW , Uri.parse("market://details?id=com.bet.compny"));
startActivity(i);
break;
but when i click on the button for rate us getting force close. here is my log cat output.
android.content.ActivityNotFoundException: No Activity found to handle Intent {
act=android.intent.action.VIEW dat=market://details?id=com.bet.compny }
Any help would be appretiated.
Idk why you get the Error, but this should actually work. I also do it like this:
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + APP_PNAME)));
But keep in mind that this would crash, if you are testing it on an Emulator/ a device without a play store. So I would suggest you to wrap it in a try and catch
This error occurs when running on a device without the Google PlayStore.
I guess you might be running this on a emulator device which doesn't have Playstore and hence the error.
Implement using try catch as follows:
try{
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id="+getPackageName())));
}
catch (ActivityNotFoundException e){
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id="+getPackageName())));
}
I am always using below code which is useful for us:
Intent rateIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + context.getPackageName()));
startActivity(rateIntent);
In think it will help full for you.
This is the best way to do it;
Appirater is an android library based off the original Appirater By
Arash Payan Appirater iPhone. The goal is to create a cleanly designed
App Rating prompt that you can drop into any android app that will
help remind your users to review your app on the android Market.
https://github.com/sbstrm/appirater-android
try {
Uri marketUri = Uri.parse("market://details?id=" + getPackageName());
Intent marketIntent = new Intent(Intent.ACTION_VIEW, marketUri);
startActivity(marketIntent);
}catch(ActivityNotFoundException e) {
Uri marketUri = Uri.parse("https://play.google.com/store/apps/details?id=" + getPackageName());
Intent marketIntent = new Intent(Intent.ACTION_VIEW, marketUri);
startActivity(marketIntent);
}
Best and Simple Code
private final String mStoreLink;
Without Activity need context/activity
this.mStoreLink = "market://details?id=" + activity.getPackageName();
Creat a method like this.
public void rateUsOnGooglePlay() {
final Uri marketUri = Uri.parse(mStoreLink);
try {
activity.startActivity(new Intent(Intent.ACTION_VIEW, marketUri));
} catch (android.content.ActivityNotFoundException ex) {
Toast.makeText(activity, "Couldn't find PlayStore on this device", Toast.LENGTH_SHORT).show();
}
}
This commonly happens on a device without the Google Play Store
i think u have test this code in emulator, and emulator have no plastore application, so this error came.
I have implement this and my code is like this.
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=applicationID of play sotre")));
please put try catch in bellow code.
and try this code in android device.
Uri marketUri = Uri.parse("market://details?id=" + packageName);
Intent marketIntent = new Intent(Intent.ACTION_VIEW, marketUri);
startActivity(marketIntent);
in my case, I wanted the user to click on "MORE BY US" and he would be redirected
to my playstore homepage, but the app was crashing. The reason was simple. I added extra spaces and lines to the link something like below:
<string name = "more_app_link">
playstore.link...............
</string>
then I removed extra lines and spaces like this:
<string name = "more_app_link">playstore.link...............</string>
and it worked very well.