我没有任何相关信息。如何使用选定的已安装应用程序填充GridView并运行这些应用程序?
我有一个教程网站,但由于我不熟悉Android,因此无法轻松关注它。 http://arnab.ch/blog/2013/08/how-to-write-custom-launcher-app-in-android/
主要活动
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.allapps_screen);
gv_selectedApps = (GridView)findViewById(R.id.gv_selectedApps);
gv_selectedApps.setAdapter(new ImageAdapter(this, MOBILE_OS));
gv_selectedApps.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View v,
int position, long id) {
Toast.makeText(
getApplicationContext(),
((TextView) v.findViewById(R.id.grid_item_label))
.getText(), Toast.LENGTH_SHORT).show();
}
});
}
答案 0 :(得分:1)
您可以从此代码中获取已安装应用的列表
final Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);
final List pkgAppsList = context.getPackageManager().queryIntentActivities( mainIntent, 0)