사용자가 휴대 전화에 설치 한 앱 목록이 필요한 애플리케이션을 개발 중입니다. 나는 지금까지 튜토리얼을 온라인으로 살펴 보았다 그리고 그들 중 누구도 즉 코드를 보여이 충분히 특정되지 않습니다하지만 결코 그것을android phone에 설치된 모든 앱 목록을 얻는 데 도움이 필요합니다.
을 넣어하지만 어디 넣어하는 방법을 알고하지 않기 때문에 프로그래밍 그래서 새로운되는 것은 내가 이것을 사용할 수없는 경우 표시 그것은 내 코드에서, 비록 그것이 작동하는 하나의 코드가 버전이나 아이콘을 보여주지 않는다는 것을 알았지 만. 나는 정말이 사람이 내 손을 잡기 위해 사용할 수있다.
내가 특별히 필요한 것은 사용자가 앱, 아이콘 및 버전을 설치 한 사용자를 보여주는 arraylist입니다. 여기
내가 작업 한 코드입니다 :패키지 com.fina을;
import java.util.ArrayList; import java.util.List; import android.app.Activity; import android.content.pm.PackageInfo; import android.graphics.drawable.Drawable; import android.os.Bundle; import android.widget.ArrayAdapter; import android.widget.ListView; import android.widget.Toast; public class scan extends Activity {
공개 ArrayList를 입술 = 새로운 ArrayList를 (); 공용 ListView 목록; public String app_labels [];
public void onCreate (Bundle savedInstanceState) { super.onCreate (savedInstanceState); setContentView (R.layout.allc);
getPackages(); list = (ListView)findViewById(R.id.listView1); try{ list.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_dropdown_item_1line, app_labels)); }catch(Exception e){ System.out.println("Err ++> " + e.getMessage()); Toast.makeText(getApplicationContext(),e.getMessage(),Toast.LENGTH_SHORT).show(); }
} 전용의 ArrayList getPackages() { ArrayList를 애플리케이션의 getInstalledApps = (FALSE); final int max = apps.size(); for (int i = 0; i < max; i ++) { apps.get (i); } 돌아 가기 앱;
:}<AbsoluteLayout android:id="@+id/absoluteLayout1" android:layout_width="fill_parent" android:layout_height="fill_parent" > <Button android:id="@+id/allcast" android:layout_width="61dp" android:layout_height="66dp" android:layout_x="0dp" android:layout_y="0dp" android:background="@drawable/invis" /> <Button android:id="@+id/downcast" android:layout_width="63dp" android:layout_height="60dp" android:layout_x="64dp" android:layout_y="3dp" android:background="@drawable/invis" /> <Button android:id="@+id/commcast" android:layout_width="51dp" android:layout_height="57dp" android:layout_x="255dp" android:layout_y="3dp" android:background="@drawable/invis" /> <Button android:id="@+id/achcast" android:layout_width="62dp" android:layout_height="58dp" android:layout_x="192dp" android:layout_y="2dp" android:background="@drawable/invis" /> <Button android:id="@+id/recocast" android:layout_width="59dp" android:layout_height="60dp" android:layout_x="128dp" android:layout_y="3dp" android:background="@drawable/invis" /> <ListView android:id="@+id/listView1" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_x="0dp" android:layout_y="71dp" > </ListView> </AbsoluteLayout>
개인 ArrayList를 getInstalledApps (부울 getSysPackages) {여기
List <PackageInfo> packs = getPackageManager().getInstalledPackages(0); try{ app_labels = new String[packs.size()]; }catch(Exception e){ Toast.makeText(getApplicationContext(),e.getMessage(),Toast.LENGTH_SHORT).show(); } for(int i=0;i < packs.size();i++) { PackageInfo p = packs.get(i); if ((!getSysPackages) && (p.versionName == null)) { continue ; } PackageInfoStruct newInfo = new PackageInfoStruct(); newInfo.appname = p.applicationInfo.loadLabel(getPackageManager()).toString(); newInfo.pname = p.packageName; newInfo.versionName = p.versionName; newInfo.versionCode = p.versionCode; newInfo.icon = p.applicationInfo.loadIcon(getPackageManager()); res.add(newInfo); app_labels[i] = newInfo.appname; } return res; } } //This class is for storing the data for each application class PackageInfoStruct { String appname = ""; String pname = ""; String versionName = ""; int versionCode = 0; Drawable icon; }
그리고 그것에 링크 내 allc.xml입니다
내가 사용할 수있는 코드가있는 웹 사이트에 대한 링크뿐만 아니라 답변에 가능한 한 구체적으로 기재하십시오. 실제로이 코드를 사용하는 사람이 필요합니다.
가능한 중복 http://stackoverflow.com/questions/ 9393676/안드로이드에 설치된 애플리케이션 목록 가져 오기) –