我的代码显示已在列表视图中具有特定权限的已安装应用。我想打开你可以在每个列表项(app)上卸载应用程序的设置。我该怎么做?
这是打开应用设置的代码段
packageName = "com.wagtailapp";
try {
// Open the specific App Info page:
Intent intent = new Intent(
android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
intent.setData(Uri.parse("package:" + packageName));
startActivity(intent);
} catch (ActivityNotFoundException e) {
// e.printStackTrace();
// Open the generic Apps page:
Intent intent = new Intent(
android.provider.Settings.ACTION_MANAGE_APPLICATIONS_SETTINGS);
startActivity(intent);
这是我的活动
public class MainActivity extends Activity {
ArrayList<String> results = new ArrayList<String>();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
getInstalledApps(this);
ArrayAdapter adapter = new ArrayAdapter<String>(this, R.layout.activity_listview, results);
ListView listView = (ListView) findViewById(R.id.mobile_list);
listView.setAdapter(adapter);
}
private ArrayList<String> getInstalledApps(Context context) {
PackageManager packageManager = context.getPackageManager();
List<PackageInfo> applist = packageManager.getInstalledPackages(0);
Iterator<PackageInfo> it = applist.iterator();
while (it.hasNext()) {
PackageInfo pk = (PackageInfo) it.next();
if ((pk.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0) {
Log.v("system app using internet = ", ""+pk.applicationInfo.loadLabel(packageManager));
continue;
}
if (PackageManager.PERMISSION_GRANTED == packageManager .checkPermission(Manifest.permission.INTERNET, pk.packageName) ||
PackageManager.PERMISSION_GRANTED == packageManager .checkPermission(Manifest.permission.READ_EXTERNAL_STORAGE, pk.packageName))
results.add("" + pk.applicationInfo.loadLabel(packageManager));
}
Log.v("app using internet = ", results.toString());
return results;
}
}
答案 0 :(得分:0)
{
"cmd": ["gcc", "${file}", "-o", "${file_base_name}.exe"],
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
"working_dir": "${file_path}",
"selector": "source.c, source.c++",
"shell": true,
"variants":
[
{
"name": "Run",
"cmd": ["start", "cmd", "/k", "${file_path}/${file_base_name}.exe"],
"shell": true
}
]
}
答案 1 :(得分:0)
Try with this:
listView.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position,
long id) {
String packageName = (String)parent.getItemAtPosition(position);
try {
// Open the specific App Info page:
Intent intent = new Intent(android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
intent.setData(Uri.parse("package:" + packageName));
startActivity(intent);
} catch (ActivityNotFoundException e) {
// e.printStackTrace();
// Open the generic Apps page:
Intent intent = new Intent( android.provider.Settings.ACTION_MANAGE_APPLICATIONS_SETTINGS);
startActivity(intent);
}
});
See if it works..
答案 2 :(得分:0)
Paste this code inside your onCreate() below listView.setAdapter(adapter);
listView.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position,
long id) {
String packageName = results.get(position);
Intent intent = new Intent(android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setData(Uri.parse("package:" + packageName));
startActivity(intent);
}
});