[Q] "New update available" dialog - Java for Android App Development

I've published an app in Play Store (https://play.google.com/store/apps/details?id=com.pikotech.bo2guide), so I've seen the number of updates is so slow, and this is a problem because I release a lot of them. I would show a "New updated available" dialog that redirect the user to my app's PlayStore tab. To do this I've thought a system to parse the source(Command+Alt+U in OS X Chrome) of my app's PlayStore Web Page. The info that stores my app's version available is this
Version Name:
Code:
itemprop="softwareVersion"> 1.0.7
How to compare on of these values with the version installed of the app? If the content parsed will be higher of the version installed, I will show a dialog with "new updated avaialble", that can redirect the user on PlayStore to updated my app.
Or there is a simple method or a library that show new "New update available" dialog

This should help you get your application version:
http://stackoverflow.com/questions/6593592/get-application-version-programatically-in-android

zalez said:
This should help you get your application version:
http://stackoverflow.com/questions/6593592/get-application-version-programatically-in-android
Click to expand...
Click to collapse
Thanks,
this is the second part of my desired dialog Code.
The first part is how to get versionName (or versionCode) off the App's Google Play Store Web Page.

rampo said:
Thanks,
this is the second part of my desired dialog Code.
The first part is how to get versionName (or versionCode) off the App's Google Play Store Web Page.
Click to expand...
Click to collapse
This is how to get the source of the Google Play page:
Code:
HttpParams params = new BasicHttpParams();
HttpConnectionParams.setConnectionTimeout(params, 4000);
HttpConnectionParams.setSoTimeout(params, 5000);
HttpClient client = new DefaultHttpClient(params);
HttpGet request = new HttpGet("https://play.google.com/store/apps/details?id=" + pkg); //your package goes here
HttpResponse response = client.execute(request);
InputStream is = response.getEntity().getContent();
BufferedReader reader = new BufferedReader(new InputStreamReader(is));
String line = null;
while((line = reader.readLine()) != null) {
//do something with the information
Log.d("line", line);
}

GitHub library coming soon
nikwen said:
This is how to get the source of the Google Play page:
Code:
HttpParams params = new BasicHttpParams();
HttpConnectionParams.setConnectionTimeout(params, 4000);
HttpConnectionParams.setSoTimeout(params, 5000);
HttpClient client = new DefaultHttpClient(params);
HttpGet request = new HttpGet("https://play.google.com/store/apps/details?id=" + pkg); //your package goes here
HttpResponse response = client.execute(request);
InputStream is = response.getEntity().getContent();
BufferedReader reader = new BufferedReader(new InputStreamReader(is));
String line = null;
while((line = reader.readLine()) != null) {
//do something with the information
Log.d("line", line);
}
Click to expand...
Click to collapse
Thanks man. I'm creating a Library to show the dialog. Follow me on GitHub.

rampo said:
Thanks man. I'm creating a Library to show the dialog. Follow me on GitHub.
Click to expand...
Click to collapse
Welcome.
You might also be interested in this library: https://github.com/MartinvanZ/Inscription
(You could fork it.)

nikwen said:
Welcome.
You might also be interested in this library: https://github.com/MartinvanZ/Inscription
(You could fork it.)
Click to expand...
Click to collapse
I already use it in my commercial app.
It's a Changelog library. I'll instead implement Styled Dialogs for the New Updated Available dialog.

rampo said:
I already use it in my commercial app.
It's a Changelog library. I'll instead implement Styled Dialogs for the New Updated Available dialog.
Click to expand...
Click to collapse
Ah, sorry. Forgot that. :silly:

Published today:
Update Checker

Related

[Q] ksoap addProperties doesn't work

Hello together,
I am trying to access a webservice with ksoap. I am able to get data from the webservice but only in the case I don't have to provide parameters.
I get always the error message "Server was unable to process request. ---> Sequence contains no elements" from the webservice. For me it looks like that the given properties are not provided to or not processed by the webservice.
I searched in the web for a couple of hours and could find out that some others have the same problem but couldn't find any solution
May anybody from the forum can help me....
My code is following
final String NAME_SPACE = "XXX";
final String URL = "XXX";
final String SOAP_ACTION = "XXX/GetMatchdataByLeagueSaison";
final String METHOD_NAME = "GetMatchdataByLeagueSaison";
SoapObject Request = new SoapObject(NAME_SPACE, METHOD_NAME);
Request.addProperty("leagueShortcut", "bl1");
Request.addProperty("leagueSaison", 2010);
SoapSerializationEnvelope soapEnvelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
soapEnvelope.dotNet = true;
soapEnvelope.setOutputSoapObject(Request);
HttpTransportSE tns = new HttpTransportSE(URL);
try
{
tns.call(SOAP_ACTION, soapEnvelope);
SoapObject resultString = (SoapObject) soapEnvelope.getResponse();
String PropertyCount = String.valueOf(resultString.getPropertyCount()); // Anzahl Records
Log.i("GetMatchdataByLeagueSaison", "Anzahl Properties = " + PropertyCount);
result = "GetMatchdataByLeagueSaison " + PropertyCount;
}
catch(Exception e)
{
result = "GetMatchdataByLeagueSaison " + e.getMessage();
}
return result;
}

Best way to get a list of installed apps?

I have the following code
Code:
PackageManager packageManager = getPackageManager();
List<PackageInfo> packs = packageManager.getInstalledPackages(0);
for (int i=0; i < packs.size(); i++) {
PackageInfo p = packs.get(i);
ApplicationInfo a = p.applicationInfo;
if ((a.flags & ApplicationInfo.FLAG_SYSTEM) == 1) {
continue;
}
// Do something here
}
This seems to work, but versonName for Moboplayer returns an empty string even though the installed version is 1.2. Why is that? It does have a version on Market
Code is taken from http://impressive-artworx.de/2011/list-all-installed-apps-in-style/ and http://stackoverflow.com/questions/4598769/list-of-user-installed-apps

[Q] Help with App permission search application

Hello,
I am student in my final year doing a project based on android development. I am thinking of creating an application that scans all the installed application in the device and recover all the list of permission associated with the app.. I will then manually use the data to check the manifest files manually, so that I can flag up any app that has more permission than it should.
I am learning and just starting creating it in eclipse. But, any advice would greatly be appreciated as am new to this development world.
I am thinking of creating a GUI for the layout but how can I make it list all the installed application on the device before I can proceed into getting the permission.
Thank you.
You need to use the PackageManager
The solution is on stackoverflow (love that site), but since I can't post links yet, I'll simply give you the code (should work):
final Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);
final List pkgAppsList = getPackageManager().queryIntentActivities(mainIntent, 0);
for (Object obj : pkgAppsList) {
ResolveInfo resolveInfo = (ResolveInfo) obj;
PackageInfo packageInfo = null;
try {
packageInfo = getPackageManager().getPackageInfo(resolveInfo.activityInfo.packageName, PackageManager.GET_PERMISSIONS);
} catch (NameNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
String[] requestedPermissions = packageInfo.requestedPermissions;
}
Good luck!!
Edwin Bos said:
You need to use the PackageManager
The solution is on stackoverflow (love that site), but since I can't post links yet, I'll simply give you the code (should work):
final Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);
final List pkgAppsList = getPackageManager().queryIntentActivities(mainIntent, 0);
for (Object obj : pkgAppsList) {
ResolveInfo resolveInfo = (ResolveInfo) obj;
PackageInfo packageInfo = null;
try {
packageInfo = getPackageManager().getPackageInfo(resolveInfo.activityInfo.packageName, PackageManager.GET_PERMISSIONS);
} catch (NameNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
String[] requestedPermissions = packageInfo.requestedPermissions;
}
Good luck!!
Click to expand...
Click to collapse
Is it possible I can create it within a searchView so that it can search it and display the installed application. But, displayed the app in a scroll view as well.

Push notifications between devices

Hello!
Sorry for my bad english.
I'm trying to develop an app that send a push notification from device A (android) to device B (android).
How can I make this app?
I can't use GCM/Parse server, 'cause a push notification is sent ONLY from server to device!
I must use a DB that save MY contacts? And then, with a query (?), sent a push notif. to user B (B have downloaded the app, of course!)?
Thanks!
Venus88 said:
I can't use GCM/Parse server,
Click to expand...
Click to collapse
Yes you can, you would just need to create an API that would capture a message sent to the server from device A then send it to device B.
Jonny said:
Yes you can, you would just need to create an API that would capture a message sent to the server from device A then send it to device B.
Click to expand...
Click to collapse
Thanks a lot!
And how I can do that? The code for GCM server, i.e. gcm.php:
PHP:
<?php
class GCM {
//put your code here
// constructor
function __construct() {
}
/**
* Sending Push Notification
*/
public function send_notification($registatoin_ids, $message) {
// include config
include_once './config.php';
// Set POST variables
$url = 'https://android.googleapis.com/gcm/send';
$fields = array(
'registration_ids' => $registatoin_ids,
'data' => $message,
);
$headers = array(
'Authorization: key=' . GOOGLE_API_KEY,
'Content-Type: application/json'
);
// Open connection
$ch = curl_init();
// Set the url, number of POST vars, POST data
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// Disabling SSL Certificate support temporarly
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields));
// Execute post
$result = curl_exec($ch);
if ($result === FALSE) {
die('Curl failed: ' . curl_error($ch));
}
// Close connection
curl_close($ch);
echo $result;
}
}
?>
and
PHP:
<?php
// response json
$json = array();
/**
* Registering a user device
* Store reg id in users table
*/
if (isset($_POST["name"]) && isset($_POST["email"]) && isset($_POST["regId"])) {
$name = $_POST["name"];
$email = $_POST["email"];
$gcm_regid = $_POST["regId"]; // GCM Registration ID
// Store user details in db
include_once './db_functions.php';
include_once './GCM.php';
$db = new DB_Functions();
$gcm = new GCM();
$res = $db->storeUser($name, $email, $gcm_regid);
$registatoin_ids = array($gcm_regid);
$message = array("product" => "shirt");
$result = $gcm->send_notification($registatoin_ids, $message);
echo $result;
} else {
// user details missing
}
?>
allows send notification from server page to one/a group of devices.
Can i "reverse" the direction? from Device A to server (and then from server to device B) automatically?
Up :\

How to open testing menu? (*#*#4636#*#*)

Basically what I am trying to do is open this testing menu (*#*#4636*#*#) via an app that I am making using Android Studio
I will leave you some screenshots so you know what I am talking about
I have the code that opens the app, but I am missing the package name and/or the activity name that will cause this menu to show up.
Code:
Intent launchIntent = getPackageManager().getLaunchIntentForPackage("com.chartcross.gpstest"); // This launches GPS test app, I need to launch the testing menu
startActivity(launchIntent);
Thank you! :good:
Try this:
Code:
Intent intent = new Intent(Intent.ACTION_DIAL);
intent.setData(Uri.parse("tel:*#*#4636#*#*"));
startActivity(intent);
or
Code:
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.setClassName("com.android.settings", "com.android.settings.TestingSettings");
startActivity(intent);
@mmdeveloper said:
Try this:
Code:
Intent intent = new Intent(Intent.ACTION_DIAL);
intent.setData(Uri.parse("tel:*#*#4636#*#*"));
startActivity(intent);
or
Code:
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.setClassName("com.android.settings", "com.android.settings.TestingSettings");
startActivity(intent);
Click to expand...
Click to collapse
Thank you very much, the second one worked fine :good:
When the testing app starts it opens this menu:
Instead, I want it to open directly this menu:
That activity is called com.android.settings.TestingSettingsBroadcastReceiver, but when I do this:
Code:
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.setClassName("com.android.settings", "com.android.settings.TestingSettingsBroadcastReceiver");
startActivity(intent);
The app just crashes with this error:
Code:
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.feche.manual3gtoggle/com.feche.manual3gtoggle.Toggle3G}: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.android.settings/com.android.settings.TestingSettingsBroadcastReceiver}; have you declared this activity in your AndroidManifest.xml?
Any idea of why? It says something that I should add to AndroidManifest.xml but since I am new to this I really don't understand to what it reffers. Thanks
EDIT:
Nevermind, I just found out that is called com.android.settings.RadioInfo instead of com.android.settings.TestingSettingsBroadcastReceiver, thanks anyways :highfive:
For your future reference,
Every class which extends activity or fragmentactivity or app combat activity etc.
Then you need to declare that particular class in your AndroidManifest.xml
mantlabs said:
Try this:
Code:
Intent intent = new Intent(Intent.ACTION_DIAL);
intent.setData(Uri.parse("tel:*#*#4636#*#*"));
startActivity(intent);
or
Code:
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.setClassName("com.android.settings", "com.android.settings.TestingSettings");
startActivity(intent);
Click to expand...
Click to collapse
above code is not working in my sample do i need to add any permissions in Manifest file can you please help in this thing
sujith.e said:
above code is not working in my sample do i need to add any permissions in Manifest file can you please help in this thing
Click to expand...
Click to collapse
What Android version are you trying? This post was almost 6 years ago.

Categories

Resources