小编lev*_*501的帖子

requestWindowFeature(Window.FEATURE_NO_TITLE); 给出了例外

import android.content.pm.ActivityInfo;
import android.os.Bundle;
import android.preference.ListPreference;
import android.preference.Preference;
import android.preference.PreferenceActivity;
import android.util.Log;
import android.view.Window;
import android.view.WindowManager;

public class OptionsActivity extends PreferenceActivity {
 private ListPreference mListPreference;

 @Override
 protected void onCreate (Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);

  setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
  requestWindowFeature(Window.FEATURE_NO_TITLE);
  getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
              getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);

  addPreferencesFromResource(R.xml.options);
  mListPreference = (ListPreference) findPreference("listpreference");
  mListPreference.setPersistent(false);  

 }
}

Exception Stacktrace is given below:
01-27 12:35:51.920: ERROR/AndroidRuntime(615): FATAL EXCEPTION: main
01-27 12:35:51.920: ERROR/AndroidRuntime(615): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.android.game/com.android.game.OptionsActivity}: android.util.AndroidRuntimeException: requestFeature() must be called before adding content
01-27 12:35:51.920: ERROR/AndroidRuntime(615):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
01-27 12:35:51.920: …
Run Code Online (Sandbox Code Playgroud)

android android-preferences

7
推荐指数
2
解决办法
4万
查看次数

如何在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) { …
Run Code Online (Sandbox Code Playgroud)

android android-widget android-emulator android-layout

6
推荐指数
2
解决办法
8407
查看次数