/[projects]/android/CheckUpdates/src/dk/thoerup/checkupdates/CheckUpdates.java
ViewVC logotype

Diff of /android/CheckUpdates/src/dk/thoerup/checkupdates/CheckUpdates.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 909 by torben, Sat Jun 26 00:04:58 2010 UTC revision 910 by torben, Sat Jun 26 07:48:40 2010 UTC
# Line 34  public class CheckUpdates { Line 34  public class CheckUpdates {
34          String title;          String title;
35                    
36                    
37          Context context;                  Context context;
38    
39          public void checkForUpdates(Context context, String url, String title) {  
40            public void checkForUpdates(Context context, String url, String title,  String apkUrl) {
41                  this.context = context;                  this.context = context;
42                  this.title = title;                  this.title = title;
43                                    
# Line 62  public class CheckUpdates { Line 63  public class CheckUpdates {
63                                                                    
64                    
65                                  UpdateTask task = new UpdateTask();                                  UpdateTask task = new UpdateTask();
66                                  task.execute(url);                                  task.execute(url, apkUrl);
67                                                                    
68    
69                          } catch (NameNotFoundException e) {                          } catch (NameNotFoundException e) {
# Line 75  public class CheckUpdates { Line 76  public class CheckUpdates {
76          class UpdateTask extends AsyncTask<String,Void,Void> {          class UpdateTask extends AsyncTask<String,Void,Void> {
77                  boolean result = false;                  boolean result = false;
78                  int newestVersion = 0;                  int newestVersion = 0;
79                    
80                    String apkUrl;
81    
82                  @Override                  @Override
83                  protected Void doInBackground(String... arg0) {                                  protected Void doInBackground(String... arg0) {                
84                          String requestUrl = arg0[0] + "?version=" + encode(versionName) + "&phone=" + encode(phone_model) + "&android=" + encode(androidVersion);                          String requestUrl = arg0[0] + "?version=" + encode(versionName) + "&phone=" + encode(phone_model) + "&android=" + encode(androidVersion);
85                            apkUrl = arg0[1];
86                            
87                          try {                          try {
88                                  URL url = new URL(requestUrl);                                  URL url = new URL(requestUrl);
89                                  URLConnection conn = url.openConnection();                                  URLConnection conn = url.openConnection();
# Line 140  public class CheckUpdates { Line 145  public class CheckUpdates {
145                                                                                    
146                                          builder.setPositiveButton("Yes", new OnClickListener() {                                                                                          builder.setPositiveButton("Yes", new OnClickListener() {                                                
147                                                  public void onClick(DialogInterface dialog, int which) {                                                  public void onClick(DialogInterface dialog, int which) {
148                                                          Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse("market://search?q=pname:" + packageName) );                                                          String launchUrl = (apkUrl == null) ? "market://search?q=pname:" + packageName : apkUrl;
149                                                            
150                                                            Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(launchUrl) );
151                                                          i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK );                                                          i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK );
152                                                          try {                                                          try {
153                                                                  context.startActivity(i);                                                                  context.startActivity(i);

Legend:
Removed from v.909  
changed lines
  Added in v.910

  ViewVC Help
Powered by ViewVC 1.1.20