OSDN Git Service

download and launch apks from the FilesDir
authoronuxy <n.nanatunoko@gmail.com>
Sun, 29 Jul 2012 14:44:57 +0000 (23:44 +0900)
committeronuxy <n.nanatunoko@gmail.com>
Sun, 29 Jul 2012 14:44:57 +0000 (23:44 +0900)
CUTEn/src/jp/ac/titech/sharp4k/cuten/LectureActivity.java
CUTEn/src/jp/ac/titech/sharp4k/cuten/TaskActivity.java

index 936ffce..022081f 100644 (file)
@@ -95,6 +95,7 @@ public class LectureActivity extends BaseMenuActivity implements OnClickListener
                }
                db.close();
                //
+               downloadApk(id);
                String apkName = id.toString() + ".apk";
                Intent intent = new Intent(this, TaskActivity.class);
                intent.putExtra(TaskActivity.TASK_NAME_KEY, task.getName());
@@ -130,4 +131,8 @@ public class LectureActivity extends BaseMenuActivity implements OnClickListener
                        }
                }
        }
+       private void downloadApk(Integer id){
+       DownloadApkTask task = new DownloadApkTask(this);
+        task.execute("http://www16307ue.sakura.ne.jp:3001/apks/"+id.toString()+"/download",id.toString()+".apk");
+    }
 }
index 39b6893..a60dc41 100644 (file)
@@ -56,8 +56,8 @@ public class TaskActivity extends Activity {
                }
                Log.d(TAG, "Try to launch " + apkName + ":" + qualName);
                try {
-                       DexClassLoader cl = loadDex(new File(
-                                       Environment.getExternalStorageDirectory(), apkName));
+                       DexClassLoader cl = loadDex(new File(getFilesDir().getPath(),
+                                       apkName));
                        Class<?> klass = cl.loadClass(qualName);
                        Log.d(TAG, "Successfully loaded " + qualName);
                        Constructor<?> ctor = klass.getConstructor();