My application needs QR code scanner app for running properly. There is no problem to request it like:
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData( Uri.parse( "market://details?id=something" ));
startActivity(intent);
After this I am redirected to Google market with predefined application. However my problem is that this code exits my main application. It is not in list. Is this a correct behaviour? When you want to install some other application does it exit other applications? Or am I doing something wrong?
Main goal is to just bring to front my main application to use it after QR code scanner is installed.
Any help is appreciated.
Have you write finish() in your previous activity from where you are redirecting to google play activity. If you have written then remove it.
final String APPLICATION_PACKAGE_ID = "com.google.zxing.client.android";
try {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + APPLICATION_PACKAGE_ID)));
} catch(ActivityNotFoundException anfe) {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://play.google.com/store/apps/details?id=" + APPLICATION_PACKAGE_ID)));
}
So I just make like it is. And when the application is installed I just hit back and it works. I dont understand how didn't work this in friday but now it is ok.
Related
I'm working on an android application, up and running at this moment. I wanted to force the existing users to upgrade the app to my latest version. This is how I went about it:
The app makes an API call to my backend server upon opening, and the server returns back a flag which signifies whether it needs to force the user to update or not
If it has to force an update, a pop up comes up and redirects the user to the playstore url upon the click of an "upgrage" button.
Now the problem is that upon click of the "upgrade" button, the playstore opens up but shows an "Item not found - Retry" screen. I've the same redirection in the "rate us" section inside the app, and it seems to be working fine there.
How do I get around this problem? Has anyone seen this before? Any help would be much appreciated.
Share your code.. try below code in your upgrade script to see if that helps
final Button btnRateUs = (Button)v.findViewById(R.id.Rate_Us);
btnRateUs.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
try {
startActivity(new Intent(
Intent.ACTION_VIEW,
Uri.parse("market://details?id=com.rachittechnology.incometaxact1961")));
} catch (android.content.ActivityNotFoundException anfe) {
startActivity(new Intent(
Intent.ACTION_VIEW,
Uri.parse("http://play.google.com/store/apps/details?id=com.rachittechnology.incometaxact1961")));
}
}
});
public void moreapp(View view){
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=(Enter id or package) "));
startActivity(intent);
}
I call GooglePlay from my app through an intent and again after I kill my own app:
Intent intent = new Intent(Intent.ACTION_VIEW);
String sModule = "market://search?q=pub:mycompany";
intent.setData(Uri.parse(sModule));
startActivity(intent);
finish();
android.os.Process.killProcess(android.os.Process.myPid());
Task manager shows, that only GooglePlay is running. My app isn't there anymore.
So my focus is GooglePlay at the moment. When going to the Desktop through the Home-Button and calling my App again it directs me to GooglePlay again.
Why is that? How can I call GooglePlay from my app independently?
I expected that when starting my app again, which I had previously killed, it would start my app and not focus on google play.
keyword is "launchMode" and "task".
this type of problems are so annoying and much complicated in android.
but this time you can try this.
Intent intent = new Intent(Intent.ACTION_VIEW);
String sModule = "market://search?q=pub:mycompany";
intent.setData(Uri.parse(sModule));
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK|Intent.FLAG_ACTIVITY_CLEAR_TASK);
startActivity(intent);
finish();
if u cant solve, try combine another flags with FLAG_ACTIVITY_NEW_TASK.
cheers!
I am developing an android app. i want to implement rate functionality in android market? There is button in app exit. I want that when i click exit an pop up should open which redirect on android market rating page. if rated already it should not redirect on android market and show you have rated alreay message. how can i achieve this.api returns anything after adding rating.
To redirect to your app you can use:
Uri marketUri = Uri.parse("market://details?id=" + packageName);
Intent marketIntent = new Intent(Intent.ACTION_VIEW, marketUri);
startActivity(marketIntent);
Also, to check if already rated or not, save a boolean in SharedPreferences and check it.
Rating an android app within an application
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse("market://details?id=com.test(package name)"));
startActivity(intent);
I have option to open my app Google Play page inside my app. When clicking open button in Google Play My app launches again. (From Splash screen)
When I am exiting my app it crashed. I tried put singleTask flag to my Home activity. It actually worked fine. But arised another crash. So I need to know is:
Is there any option to put flag in my Market calling Intent to notify that the app is already launched and just bring it front on clicking Open button?
Here how am I calling GooglePlay app.
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(marketUrl));
try {
startActivity(intent);
} catch (ActivityNotFoundException e) {
Toast.makeText(this, "Cannot find Android Market",
Toast.LENGTH_LONG).show();
}
EDIT
My market url: market://details?id=com.foo.bar
This will directly redirect to my apps Installation page.
use this code..
Uri uri = Uri.parse(https://play.google.com/store);
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(intent);
In the included LVL sample app, the license check is triggered during onCreate. This means that when I click "Buy App" to launch the market, then immediately hit the back button to return to the app, the dialog is gone and another check isn't performed, leaving me with a perfectly usable app (at least until the activity is killed and the process starts over again).
Would triggering the license check during onResume() be bad form, even though it would fix this issue? Is there a better solution?
After further research (and some experience) it appears that using onCreate() to check the license is fine. If you're sticking with the dialog method, adding finish() to the function that goes to the market will ensure that somebody can't just "back" into the app from the market and use it normally. They'll have to re-launch the app, which then triggers the license check again.
Make sure you set the dialog to cancelable(false) or else they can just hit the back button without responding to the dialog choices.
Wirbly,
Did you put finish(); before or after the intent:
finish();
Intent marketIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(
"http://market.android.com/details?id=" + getPackageName()));
startActivity(marketIntent);
or,
Intent marketIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(
"http://market.android.com/details?id=" + getPackageName()));
startActivity(marketIntent);
finish();
Thanks.