Parse API push notification, open app page on play store - android

So on are our app we have Parse API, to send push notification and manage backend stuff, we are sending and update the app notificaiton bt clicking the notification it opens the APP, we would like it to open the store page for our APP, is it possible?

i have used this code so far.You can check if the Google Play Store app is installed and, if this is the case, you can use the "market://" protocol. just write your code instead from where you try to open your app actvity from notification panel.
final String my_package_name = "........." // <- HERE YOUR PACKAGE NAME!!
String url = "";
try {
//Check whether Google Play store is installed or not:
this.getPackageManager().getPackageInfo("com.android.vending", 0);
url = "market://details?id=" + my_package_name;
} catch ( final Exception e ) {
url = "https://play.google.com/store/apps/details?id=" + my_package_name;
}
//Open the app page in Google Play store:
final Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
startActivity(intent);

Related

How to open the Huawei AppGallery directly?

I know that is possible to open my app (based on package name) in Google Play Store, but how to do same in Huawei AppGallery?
Opening your app in the Huawei App Gallery is similar to opening Google Play Store:
Huawei App Gallery:
Scheme: market:// or appmarket://
Package: com.huawei.appmarket
vs. Google Play Store:
Scheme: market://
Package: com.android.vending
Here is a snippet for the Huawei App Gallery:
private void startHuaweiAppGallery() {
Uri detailsUri = Uri.parse("market://details?id=" + getPackageName());
Intent intent = new Intent(Intent.ACTION_VIEW, detailsUri);
List<ResolveInfo> otherApps =
getPackageManager().queryIntentActivities(intent, 0);
for (ResolveInfo app : otherApps) {
String packageName = app.activityInfo.applicationInfo.packageName;
if (!packageName.equals("com.huawei.appmarket")) {
continue;
}
intent.addFlags(
Intent.FLAG_ACTIVITY_NEW_TASK |
Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED |
Intent.FLAG_ACTIVITY_CLEAR_TOP
);
intent.setComponent(new ComponentName(packageName, app.activityInfo.name));
startActivity(intent);
return;
}
//Huawei App Gallery N/A. Open app link in browser.
//Huawei App ID can be found in the Huawei developer console
final string huaweiAppID = "100864605";
//ex. https://appgallery.cloud.huawei.com/marketshare/app/C100864605
Uri appUri = Uri.parse(
"https://appgallery.cloud.huawei.com/marketshare/app/C" + huaweiAppID
);
intent = new Intent(Intent.ACTION_VIEW, appUri);
startActivity(intent);
}
Here is the snippet for Google Play:
private void startGooglePlay() {
Uri detailsUri = Uri.parse("market://details?id=" + getPackageName());
Intent intent = new Intent(Intent.ACTION_VIEW, detailsUri);
List<ResolveInfo> otherApps =
getPackageManager().queryIntentActivities(intent, 0);
for (ResolveInfo app : otherApps) {
String packageName = app.activityInfo.applicationInfo.packageName;
if (!packageName.equals("com.android.vending")) {
continue;
}
intent.addFlags(
Intent.FLAG_ACTIVITY_NEW_TASK |
Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED |
Intent.FLAG_ACTIVITY_CLEAR_TOP
);
intent.setComponent(new ComponentName(packageName, app.activityInfo.name));
startActivity(intent);
return;
}
//Google Play N/A. Open app link in browser.
Uri appUri = Uri.parse(
"https://play.google.com/store/apps/details?id=" + getPackageName()
);
intent = new Intent(Intent.ACTION_VIEW, appUri);
startActivity(intent);
}
Here is the snippet to allow the user to pick Any Available Store on the device:
private void startAnyStore() {
Uri detailsUri = Uri.parse("market://details?id=" + getPackageName());
Intent intent = new Intent(Intent.ACTION_VIEW, detailsUri);
intent.addFlags(
Intent.FLAG_ACTIVITY_NEW_TASK |
Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED |
Intent.FLAG_ACTIVITY_CLEAR_TOP
);
startActivity(intent);
}
I agree with #Pierre
But I also think you can resolve activity with links
https://appgallery8.huawei.com/#/app/C<HUAWEI_APP_ID>
or
https://appgallery.cloud.huawei.com/uowap/index.html#/detailApp/C<HUAWEI_APP_ID>?appId=C<HUAWEI_APP_ID>
For example, https://appgallery.cloud.huawei.com/uowap/index.html#/detailApp/C101652909?appId=C101652909
If your application has already released on the Huawei Appgallery, then you can use this url to open the application directly.
URL with the appid of your applcation, for example the AppGallery's appid is 27162, then can open it with this URL
https://appgallery.huawei.com/#/app/C27162
You can replace the appid with your own appid .
URL with the package name of your application, for example the AppGallery's package name is com.huawei.appmarket, then can open it with this URL
https://appgallery.cloud.huawei.com/appDetail?pkgName=com.huawei.appmarket
You can replace the package name with your own package name.
Wish it can be helpful.
It seems Huawei App Gallery can now open the details page with the same URI that works for Google Play: market://details?id=<applicationId>
I just tried it out on AppGallery v11.1.2.304 with an applicationId that exists on both stores:
adb shell am start -a "android.intent.action.VIEW" -d "market://details?id=busu.blackscreenbatterysaver"
A simple way to open app in Huawei App Gallery store:
public void reviewApp(String packageName){
try {
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("appmarket://details?id=" + packageName));
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
} catch (ActivityNotFoundException anfe) {
Toast.makeText(this, "Huawei AppGallery not found!", Toast.LENGTH_SHORT).show();
}
}
then call it from your activity:
reviewApp(this.getPackageName());
or:
reviewApp("com.myapp.android");
You can use the badge service provided by HUAWEI AppGallery to promote your app, including preparing materials for making a badge, configuring an app link, and obtaining referrer statistics. With the service, you can efficiently collect statistics on app downloads in AppGallery and provide the silent installation service for users to improve the promotion effect.
When a user taps your badge in a channel, the user is redirected to your app details page on AppGallery. The user can tap Install to automatically download and install your app.
Making a badge
Sign in to AppGallery Connect and click In-app distribution.
Click the Make badge tab.
Click Add and add an app either by searching by keyword or app ID. (You can only make a badge for a released app.)
Set Badge type, Display badge in, Channel name, and Referrer. The referrer is optional. If attribution statistics is required, you need to set the parameter.
Click Generate badge to obtain the badge and its link.
Check the screenshot below:
Launch Play Store/AppGallery via package name.
private boolean openInStore(String uri){
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED | Intent.FLAG_ACTIVITY_CLEAR_TOP);
try {
startActivity(Intent.createChooser(intent,getString(R.string.open_with)));
return true;
} catch (ActivityNotFoundException anfe) {
return false;
}
}
private void startOpenInStore() {
String playStoreScheme = "market://details?id=", huaweiScheme = "appmarket://details?id=";
if (!openInStore(playStoreScheme+getPackageName())) {
if (!openInStore(huaweiScheme + getPackageName())) {
openInStore("https://play.google.com/store/apps/details?id=" + getPackageName());
}
}
}
As for how to link to an app detail page or an app list page on AppGallery:
• The link that you referred: here is to an app detail page. Huawei does support the app detail page using badge service on AppGallery. In other words, you can replace the Google link with Huawei badge link. You can get the detail information of badge service at here
• For app listing on AppGallery, Huawei has not opened the ability to all developers except some invited developers.
Hope this help and let me know if any questions.
Here is how to start App Gallery directly:
Intent intent = new Intent(Intent.ACTION_VIEW);
Uri.Builder uriBuilder = Uri.parse("https://appgallery.cloud.huawei.com/ag").buildUpon();
intent.setData(uriBuilder.build());
intent.setPackage("com.huawei.appmarket");
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
I think the shortest and easiest one would be running this simple link: https://appgallery.cloud.huawei.com/ag/n/app/<YOUR_APP_ID>.
No need to config anything and the rest will handled by Huawei automatically.
How to get YOUR_APP_ID?
Go to Huawei App Gallery
Search for your app (e.g. WeChat)
Copy the ID in the end of the link (e.g. https://appgallery.huawei.com/#/app/C5683)
In this case the APP_ID for WeChat would be C5683
So the Huawei app link for WeChat would be https://appgallery.cloud.huawei.com/ag/n/app/C5683
Ok bro. You can use the package name. com.huawei.appmarket and use Intent. There is a similar question here. Launch an application from another application on Android
Good luck for whatever you doing 😊

Send whatsApp message using background Service without opening whatsApp

I am trying to build a background service in which I can send message from my whatsapp to the other user's whatsapp.
I've tried this code
PackageManager packageManager = getApplicationContext().getPackageManager();
Intent i = new Intent(Intent.ACTION_VIEW);
try {
String url = "https://api.whatsapp.com/send?phone=" + "+91 7*********" + "&text=" + URLEncoder.encode("hhellow User", "UTF-8");
i.setPackage("com.whatsapp");
i.setData(Uri.parse(url));
if (i.resolveActivity(packageManager) != null) {
startActivity(i);
}
} catch (Exception e) {
e.printStackTrace();
}
But it is again redirecting me to whatsapp and ask me to send the message. I don't want to open my whatsapp screen, message should directly be send to the user (in background).
I know this question is already asked but I didn't get my answer all are redirecting me to whatsApp.
As per the WhatsApp FAQ there are only two ways to send text
Using Url
Using Intent
In both cases users have to click send button explicitly to send the message.
So as of now it is not possible to send message directly using any background service without clicking send button from WhatsApp itself.

Waze - open waze.to links in app and start navigation,

I would like to open the Waze app from a web browser but the links I have in my db are in this format:
http://waze.to/li/hsv9hc540y
https://waze.to/li/hsv8v8wv81
When I click on these links from my mobile web browser they open the app but the navigation doesn't begin, it's only opens the app and that's it.
After reading the updated waze api I haven't found a way to navigate using the encrypted string hsv9hc540y only by latitude and longitude which I don't have.
How can I convert those waze.to links to the new deep links api using the encrypted string I have so it will open the app and init navigation?
Your deep links are not correct. To make them work, they need to look like this:
https://waze.com/ul/hsv9hc540y
https://waze.com/ul/hsv8v8wv81
For more info, check this link:
https://developers.google.com/waze/deeplinks/
try {
// Launch Waze
String mapRequest = "https://waze.com/ul?q=" + latLng.latitude + "," + latLng.longitude + "&navigate=yes&zoom=17";
Uri gmmIntentUri = Uri.parse(mapRequest);
Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri);
mapIntent.setPackage("com.waze");
startActivity(mapIntent);
} catch (ActivityNotFoundException e)
{
// If Waze is not installed, open it in Google Play
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=com.waze"));
startActivity(intent);
}

How to redirect to my play store app listing in Android

i am developing an app in which i added a button named "More Apps", what i want is when user click on that button it should redirect to the play store showing app listing of my account.
i did the following code :
String url_more_app = "https://play.google.com/store/search?q=rajesh%20panchal&hl=en";
case R.id.btn_more_app:
Intent viewIntent =
new Intent("android.intent.action.VIEW",
Uri.parse(url_more_app ));
startActivity(viewIntent);
break;
but when clicking on that button its showing app listing of my apps as well as apps by others,
how can i display only my apps??
Change URL from
String url_more_app = "https://play.google.com/store/search?q=rajesh%20panchal&hl=en";
TO
https://play.google.com/store/apps/developer?id=Rajesh+Panchal
have a look this
final String appPackageName = "com.example"; // Can also use getPackageName(), as below
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + appPackageName)));
Google Doc
Launch Google Play Store works fine with some Market URI:
String market_uri = "https://play.google.com/store/search?q=pub:maven&hl=en";
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(<market_uri>));
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NO_ANIMATION);
startActivity(intent);
where uris can be
market://details?id=
market://search?q=pub:
like mine

PackageManager does not work on Android 2.3.4

I am launching the default Youtube App installed on device to play a video. First, I want to check if the app exists on the device using PackageManager.
If the app does not exists, I want to redirect the user to the Google Play to download the app.
Below is the code snippet:
String appName = "com.google.android.youtube";
Boolean existFlg = false;
Context context = getApplicationContext();
PackageManager packageManager = context.getPackageManager();
// get all installed app's info
List<PackageInfo> pinfo = packageManager.getInstalledPackages(PackageManager.GET_ACTIVITIES);
for (int i = 0; i < pinfo.size(); i++) {
String name = pinfo.get(i).packageName;
if (name.equalsIgnoreCase(appName)) {
existFlg = true;
break;
}
}
if (existFlg) {
// start Youtube Native App
Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse("vnd.youtube:"+video_id));
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(i);
}
// not installed
else {
// goto the market to download Youtube App
Uri uri = Uri.parse("market://details?id=com.google.android.youtube");
Intent market = new Intent(Intent.ACTION_VIEW, uri);
market.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
try {
context.startActivity(market);
} catch (android.content.ActivityNotFoundException ex) {
// if market app not exist, goto the web of Google Play to download the Facebook App
String googleURL = "https://play.google.com/store/apps/details?id=com.google.android.youtube";
Uri googleplay_webpage = Uri.parse(googleURL);
Intent marketIntent = new Intent(Intent.ACTION_VIEW, googleplay_webpage);
marketIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(marketIntent);
}
}
This code works perfectly well on Android 4.0.4 and above. But when I am trying to run it on Android 2.3.4 it ALWAYS redirects the user to the Google Play irrespective of whether the App is installed or not.
Any idea as to how to make this compatible with Android 2.3.4 too ?
It is probably because PackageManager.GET_ACTIVITIES doesn't really make much sense here?
You probably want something like:
try {
PackageInfo pi = pm.getPackageInfo("com.google.android.youtube", 0);
// start Youtube
} catch (NameNotFoundException e) {
// go to Play Store
}
Also a better approach would be not to force the Youtube app on the user, but simply use the VIEW action and let them choose the app they want to use.

Categories

Resources