package com.App.Detect;
import android.app.Activity;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.widget.*;
public class MainActivity extends Activity
{
TextView t;
@Override
protected void onCreate(Bundle savedInstanceState)
{
t = (TextView)findViewById(R.id.TextView);
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
//Put the package name here...
boolean installed = isAppInstalled("com.my.detect.prokey");
if (installed)
{
t.setText("App already installed on your android");
}
else
{
t.setText("Sorry,App is not installed on your android");
}
}
private boolean isAppInstalled(String packageName)
{
PackageManager pm = getPackageManager();
boolean installed = false;
try
{
pm.getPackageInfo(packageName, PackageManager.GET_ACTIVITIES);
installed = true;
}
catch (PackageManager.NameNotFoundException e)
{
installed = false;
}
return installed;
}
}
我試圖創建一個專業密鑰來禁用廣告並啓用高級功能。應用程序在檢測到應用程序時崩潰
我搜索並發現此代碼修改「systemoutprintin」爲t(textview),但應用程序立即崩潰,我該怎麼辦?
安置自己的logcat的。 –