Este es el código que tengo en este momento pero aún no puedo obtener una lista de todas las aplicaciones en el teléfono. ¿Alguien ve lo que estoy haciendo mal?Cómo obtener todas las aplicaciones instaladas en el teléfono Android
public class GetAppList extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
try {
List<PackageInfo> appListInfo1 = this.getPackageManager()
.getInstalledPackages(0);
JSONArray ja = new JSONArray();
try {
HttpClient httpclient = new DefaultHttpClient();
Object sendDataUrl = null;
HttpPost request = new HttpPost(sendDataUrl.toString());
List<NameValuePair> params = new ArrayList<NameValuePair>();
ContextWrapper context = null;
PackageManager pm = context.getPackageManager();
List<PackageInfo> appListInfo = pm.getInstalledPackages(0);
for (PackageInfo p : appListInfo) {
if (p.applicationInfo.uid > 10000) {
JSONObject jo = new JSONObject();
jo.put("label", p.applicationInfo.loadLabel(pm).toString());
jo.put("packageName", p.applicationInfo.packageName);
ja.put(jo);
}
System.out.print(ja);
}
} catch (Exception e) {
// TODO: handle exception
}
finally {
// ... cleanup that will execute whether or not an error occurred ...
}
}catch (Exception e) {
// TODO: handle exception
}
finally {
// ... cleanup that will execute whether or not an error occurred ...
}
}}
Lo siento, no puedo obtener esto para formatear el código correctamente.
Este código no se corta y pega como correcto (errores alrededor de String activityName y pkg) ... solo FYI – easycheese