-1

我最终删除了声音活动,并且与它和应用程序相关的所有调用都有效。

尝试添加 tabSpec 时,我的应用程序强制关闭。我昨天有一个正在运行的构建,但没有保存它,当我编辑它时,我的规范没有添加正确。我研究了基本相同的问题,但这些答案没有帮助。这是我的代码

控制活动

package com.control.driswave;


import android.app.TabActivity;
import android.content.Intent;
import android.content.res.Resources;
import android.os.Bundle;
import android.widget.TabHost;
import android.widget.Toast;

import com.control.driswave.R;
import com.stericson.RootTools.RootTools;

public class ControlActivity extends TabActivity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    if (RootTools.isAccessGiven()) {
        Toast root = Toast.makeText(getApplicationContext(), 
                "Root Granted", Toast.LENGTH_SHORT);
        root.show();
    } else {
        Toast noRoot = Toast.makeText(getApplicationContext(), 
                "Root Access Needed To Continue", Toast.LENGTH_LONG);
        noRoot.show();
        finish();
    }

    Resources res = getResources(); // used to get res drawings (i.e. display files)
    TabHost tabHost = getTabHost(); // used to create TabHost located in main.xml
    TabHost.TabSpec spec; //TabHost specifications which are the same in each view
    Intent intent; //intent for each tab. *RESEARCH INTENT*


    // New Class Added Caused FC. Was working. Spec no longer working again.

     //____Display
    intent = new Intent().setClass(this, DisplayActivity.class);

    spec = tabHost.newTabSpec("display").setIndicator("Display",
            res.getDrawable(R.drawable.ic_tab_display))
            .setContent(intent); // create picture to be used for tab
    tabHost.addTab(spec);

    //____Power
    intent = new Intent().setClass(this, PowerActivity.class);

    spec = tabHost.newTabSpec("power").setIndicator("Power", 
            res.getDrawable(R.drawable.ic_tab_display))
            .setContent(intent);
    tabHost.addTab(spec);

    //____Sound
    intent = new Intent().setClass(this, SoundActivity.class);

    spec = tabHost.newTabSpec("sound").setIndicator("Sound",
            res.getDrawable(R.drawable.ic_tab_display))
            .setContent(intent);
    tabHost.addTab(spec);

    tabHost.setCurrentTab(2);

显示活动

package com.control.driswave;

import java.io.File;

import com.stericson.RootTools.RootTools;

import android.app.Activity;
import android.os.Bundle;
import android.provider.Settings;
import android.widget.CheckBox;
import android.widget.Toast;

public class DisplayActivity extends Activity {
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.display);


    //_____Disable Boot Animation_____//
    CheckBox dba = (CheckBox) findViewById(R.id.DBA);
    if (dba.isChecked()) {
        RootTools.remount("/system/", "rw");
        File ba = new File("/System/Media/bootanimation.zip");
        ba.renameTo(new File("/System/Media/bootanimation.zip.bak"));
        Toast.makeText(getApplicationContext(), "Boot Animation Disabled", Toast.LENGTH_SHORT);

    }

    //_____Disable Window Animations_____//
    CheckBox dwa = (CheckBox) findViewById(R.id.DWA);
    if (dwa.isChecked()) {
        Settings.System.putInt(getContentResolver(), Settings.System.WINDOW_ANIMATION_SCALE, 0);
    } else {
        Settings.System.putInt(getContentResolver(), Settings.System.WINDOW_ANIMATION_SCALE, 1);

    }

}

}

显示.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >

<TextView
    android:id="@+id/textView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/bcTitle"
    android:textAppearance="?android:attr/textAppearanceSmall" />

<CheckBox
    android:id="@+id/DBA"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="@string/dabCB" />

<CheckBox
    android:id="@+id/DWA"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="@string/DWA" />

主.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.control.driswave"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk android:minSdkVersion="10" />

<application
    android:debuggable="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name" >
    <activity
        android:name=".ControlActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity
        android:name=".DisplayActivity"
        android:label="@string/displaytab" >
    </activity>
    <activity
        android:name=".PowerActivity"
        android:label="@string/powertab" >
    </activity>
    <activity
        android:name=".SoundActivity"
        android:label="@string/soundtab" >
    </activity>
</application>

日志猫

06-17 15:33:32.927: E/dalvikvm(18685): could not disable core file generation for pid 18685: Operation not permitted
06-17 15:33:33.075: D/dalvikvm(18685): GC_EXPLICIT freed 57K, 43% free 3067K/5379K, external 2540K/2666K, paused 35ms
06-17 15:33:34.380: D/AndroidRuntime(18685): Shutting down VM
06-17 15:33:34.380: W/dalvikvm(18685): threadid=1: thread exiting with uncaught exception (group=0x4001e560)
06-17 15:33:34.466: E/AndroidRuntime(18685): FATAL EXCEPTION: main
06-17 15:33:34.466: E/AndroidRuntime(18685): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.control.driswave/com.control.driswave.ControlActivity}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.control.driswave/com.control.driswave.DisplayActivity}: java.lang.SecurityException: Permission Denial: writing com.android.providers.settings.OverlaySettingsProvider uri content://settings/system from pid=18685, uid=10125 requires android.permission.WRITE_SETTINGS
06-17 15:33:34.466: E/AndroidRuntime(18685):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1702)
06-17 15:33:34.466: E/AndroidRuntime(18685):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1722)
06-17 15:33:34.466: E/AndroidRuntime(18685):    at android.app.ActivityThread.access$1500(ActivityThread.java:124)
06-17 15:33:34.466: E/AndroidRuntime(18685):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:974)
06-17 15:33:34.466: E/AndroidRuntime(18685):    at android.os.Handler.dispatchMessage(Handler.java:99)
06-17 15:33:34.466: E/AndroidRuntime(18685):    at android.os.Looper.loop(Looper.java:130)
06-17 15:33:34.466: E/AndroidRuntime(18685):    at android.app.ActivityThread.main(ActivityThread.java:3821)
06-17 15:33:34.466: E/AndroidRuntime(18685):    at java.lang.reflect.Method.invokeNative(Native Method)
06-17 15:33:34.466: E/AndroidRuntime(18685):    at java.lang.reflect.Method.invoke(Method.java:507)
06-17 15:33:34.466: E/AndroidRuntime(18685):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
06-17 15:33:34.466: E/AndroidRuntime(18685):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
06-17 15:33:34.466: E/AndroidRuntime(18685):    at dalvik.system.NativeStart.main(Native Method)
06-17 15:33:34.466: E/AndroidRuntime(18685): Caused by: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.control.driswave/com.control.driswave.DisplayActivity}: java.lang.SecurityException: Permission Denial: writing com.android.providers.settings.OverlaySettingsProvider uri content://settings/system from pid=18685, uid=10125 requires android.permission.WRITE_SETTINGS
06-17 15:33:34.466: E/AndroidRuntime(18685):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1702)
06-17 15:33:34.466: E/AndroidRuntime(18685):    at android.app.ActivityThread.startActivityNow(ActivityThread.java:1530)
06-17 15:33:34.466: E/AndroidRuntime(18685):    at android.app.LocalActivityManager.moveToState(LocalActivityManager.java:127)
06-17 15:33:34.466: E/AndroidRuntime(18685):    at android.app.LocalActivityManager.startActivity(LocalActivityManager.java:339)
06-17 15:33:34.466: E/AndroidRuntime(18685):    at android.widget.TabHost$IntentContentStrategy.getContentView(TabHost.java:696)
06-17 15:33:34.466: E/AndroidRuntime(18685):    at android.widget.TabHost.setCurrentTab(TabHost.java:328)
06-17 15:33:34.466: E/AndroidRuntime(18685):    at android.widget.TabHost.addTab(TabHost.java:218)
06-17 15:33:34.466: E/AndroidRuntime(18685):    at com.control.driswave.ControlActivity.onCreate(ControlActivity.java:46)
06-17 15:33:34.466: E/AndroidRuntime(18685):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
06-17 15:33:34.466: E/AndroidRuntime(18685):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1666)
06-17 15:33:34.466: E/AndroidRuntime(18685):    ... 11 more
06-17 15:33:34.466: E/AndroidRuntime(18685): Caused by: java.lang.SecurityException: Permission Denial: writing com.android.providers.settings.OverlaySettingsProvider uri content://settings/system from pid=18685, uid=10125 requires android.permission.WRITE_SETTINGS
06-17 15:33:34.466: E/AndroidRuntime(18685):    at android.os.Parcel.readException(Parcel.java:1322)
06-17 15:33:34.466: E/AndroidRuntime(18685):    at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:183)
06-17 15:33:34.466: E/AndroidRuntime(18685):    at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:137)
06-17 15:33:34.466: E/AndroidRuntime(18685):    at android.content.ContentProviderProxy.insert(ContentProviderNative.java:460)
06-17 15:33:34.466: E/AndroidRuntime(18685):    at android.content.ContentResolver.insert(ContentResolver.java:608)
06-17 15:33:34.466: E/AndroidRuntime(18685):    at android.provider.Settings$NameValueTable.putString(Settings.java:604)
06-17 15:33:34.466: E/AndroidRuntime(18685):    at android.provider.Settings$System.putString(Settings.java:813)
06-17 15:33:34.466: E/AndroidRuntime(18685):    at android.provider.Settings$System.putInt(Settings.java:896)
06-17 15:33:34.466: E/AndroidRuntime(18685):    at com.control.driswave.DisplayActivity.onCreate(DisplayActivity.java:34)
06-17 15:33:34.466: E/AndroidRuntime(18685):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
06-17 15:33:34.466: E/AndroidRuntime(18685):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1666)
06-17 15:33:34.466: E/AndroidRuntime(18685):    ... 20 more
4

1 回答 1

0

android.permission.WRITE_SETTINGS在你的 Android 清单文件中有权限吗?

于 2012-06-17T20:45:54.920 回答