-1

当我添加一些东西时,DisplayActivity.java 的规范总是崩溃。无法弄清楚我做错了什么。这是我当前的代码。

控件活动.java

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);





}
}

显示活动.java

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.view.View.OnClickListener;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.SeekBar;
import android.widget.SeekBar.OnSeekBarChangeListener;
import android.widget.TextView;
import android.widget.Toast;

public class DisplayActivity extends Activity {
private int prevValue = Integer.parseInt(Settings.System.WINDOW_ANIMATION_SCALE);
private SeekBar brBar;
private TextView brightLevel;

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.display);


    //_____Disable Boot Animation_____// NEEDS TESTING http://mgmblog.com/2008/02/18/android-checkbox-oncheckedchangelistener/
    CheckBox dba = (CheckBox) findViewById(R.id.DBA);
    dba.setOnCheckedChangeListener(new OnCheckedChangeListener() {

        public void onCheckedChanged(CompoundButton dba, boolean isChecked) {
            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);
            } else {
                Toast.makeText(getApplicationContext(), "Boot Animation Enabled", Toast.LENGTH_SHORT);
            }

        }

    });




    //_____Disable Window Animations_____//
    CheckBox dwa = (CheckBox) findViewById(R.id.DWA);
    dwa.setOnCheckedChangeListener(new OnCheckedChangeListener() {
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {

            if (buttonView.isChecked()) {
                Settings.System.putInt(getContentResolver(), Settings.System.WINDOW_ANIMATION_SCALE, 0);
            } else {
                Settings.System.putInt(getContentResolver(), Settings.System.WINDOW_ANIMATION_SCALE, prevValue);
            }
        }
    });


    //_____Brightness Seek Bar____//
    brBar = (SeekBar) findViewById(R.id.brSeekbar);
    brightLevel = (TextView) findViewById(R.id.brSeekbar_num);
    brBar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {

        public void onProgressChanged(SeekBar brBar, int brLevel, boolean arg2) {
            Settings.System.putInt(getContentResolver(), Settings.System.SCREEN_BRIGHTNESS, brLevel);
            brightLevel.setText(brLevel);

        }

        public void onStartTrackingTouch(SeekBar brBar) {
            brightLevel.setText("Changing...");

        }

        public void onStopTrackingTouch(SeekBar brBar) {
            // Nothing

        }


    });




}

}

显示.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" />

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

<SeekBar
    android:id="@+id/brSeekbar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" />

<TextView
    android:id="@+id/brSeekbar_num"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:gravity="center_horizontal"
    android:text="@string/brightlevel"
    android:textAppearance="?android:attr/textAppearanceMedium" />

控制清单.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" />
<uses-permission android:name="android.permission.WRITE_SETTINGS"/>
<uses-permission android:name="android.permission.CHANGE_CONFIGURATION"/>
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE"/>
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE"/>
<uses-permission android:name="android.permission.DEVICE_POWER"/>
<uses-permission android:name="android.permission.FLASHLIGHT"/>
<uses-permission android:name="android.permission.KILL_BACKGROUND_PROCESSES"/>
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS"/>
<uses-permission android:name="com.android.browser.permission.READ_HISTORY_BOOKMARKS"/>
<uses-permission android:name="android.permission.SET_ORIENTATION"/>
<uses-permission android:name="android.permission.SET_ANIMATION_SCALE"/>
<uses-permission android:name="android.permission.VIBRATE"/>
<uses-permission android:name="com.android.browser.permission.WRITE_HISTORY_BOOKMARKS"/>
<uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS"/>
<uses-permission android:name="android.permission.READ_SYNC_SETTINGS"/>
<uses-permission android:name="android.permission.WRITE_SYNC_SETTINGS"/>

<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>


</application>

日志文件

06-25 17:38:44.035: D/dalvikvm(25731): GC_EXPLICIT freed 58K, 43% free 3067K/5379K, external 2540K/2666K, paused 41ms
06-25 17:38:48.293: D/AndroidRuntime(25731): Shutting down VM
06-25 17:38:48.293: W/dalvikvm(25731): threadid=1: thread exiting with uncaught exception (group=0x4001e560)
06-25 17:38:48.332: E/AndroidRuntime(25731): FATAL EXCEPTION: main
06-25 17:38:48.332: E/AndroidRuntime(25731): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.control.driswave/com.control.driswave.ControlActivity}: java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.control.driswave/com.control.driswave.DisplayActivity}: java.lang.NumberFormatException: unable to parse 'window_animation_scale' as integer
06-25 17:38:48.332: E/AndroidRuntime(25731):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1702)
06-25 17:38:48.332: E/AndroidRuntime(25731):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1722)
06-25 17:38:48.332: E/AndroidRuntime(25731):    at android.app.ActivityThread.access$1500(ActivityThread.java:124)
06-25 17:38:48.332: E/AndroidRuntime(25731):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:974)
06-25 17:38:48.332: E/AndroidRuntime(25731):    at android.os.Handler.dispatchMessage(Handler.java:99)
06-25 17:38:48.332: E/AndroidRuntime(25731):    at android.os.Looper.loop(Looper.java:130)
06-25 17:38:48.332: E/AndroidRuntime(25731):    at android.app.ActivityThread.main(ActivityThread.java:3821)
06-25 17:38:48.332: E/AndroidRuntime(25731):    at java.lang.reflect.Method.invokeNative(Native Method)
06-25 17:38:48.332: E/AndroidRuntime(25731):    at java.lang.reflect.Method.invoke(Method.java:507)
06-25 17:38:48.332: E/AndroidRuntime(25731):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
06-25 17:38:48.332: E/AndroidRuntime(25731):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
06-25 17:38:48.332: E/AndroidRuntime(25731):    at dalvik.system.NativeStart.main(Native Method)
06-25 17:38:48.332: E/AndroidRuntime(25731): Caused by: java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.control.driswave/com.control.driswave.DisplayActivity}: java.lang.NumberFormatException: unable to parse 'window_animation_scale' as integer
06-25 17:38:48.332: E/AndroidRuntime(25731):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1624)
06-25 17:38:48.332: E/AndroidRuntime(25731):    at android.app.ActivityThread.startActivityNow(ActivityThread.java:1530)
06-25 17:38:48.332: E/AndroidRuntime(25731):    at android.app.LocalActivityManager.moveToState(LocalActivityManager.java:127)
06-25 17:38:48.332: E/AndroidRuntime(25731):    at android.app.LocalActivityManager.startActivity(LocalActivityManager.java:339)
06-25 17:38:48.332: E/AndroidRuntime(25731):    at android.widget.TabHost$IntentContentStrategy.getContentView(TabHost.java:696)
06-25 17:38:48.332: E/AndroidRuntime(25731):    at android.widget.TabHost.setCurrentTab(TabHost.java:328)
06-25 17:38:48.332: E/AndroidRuntime(25731):    at android.widget.TabHost.addTab(TabHost.java:218)
06-25 17:38:48.332: E/AndroidRuntime(25731):    at com.control.driswave.ControlActivity.onCreate(ControlActivity.java:46)
06-25 17:38:48.332: E/AndroidRuntime(25731):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
06-25 17:38:48.332: E/AndroidRuntime(25731):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1666)
06-25 17:38:48.332: E/AndroidRuntime(25731):    ... 11 more
06-25 17:38:48.332: E/AndroidRuntime(25731): Caused by: java.lang.NumberFormatException: unable to parse 'window_animation_scale' as integer
06-25 17:38:48.332: E/AndroidRuntime(25731):    at java.lang.Integer.parse(Integer.java:383)
06-25 17:38:48.332: E/AndroidRuntime(25731):    at java.lang.Integer.parseInt(Integer.java:372)
06-25 17:38:48.332: E/AndroidRuntime(25731):    at java.lang.Integer.parseInt(Integer.java:332)
06-25 17:38:48.332: E/AndroidRuntime(25731):    at com.control.driswave.DisplayActivity.<init>(DisplayActivity.java:20)
06-25 17:38:48.332: E/AndroidRuntime(25731):    at java.lang.Class.newInstanceImpl(Native Method)
06-25 17:38:48.332: E/AndroidRuntime(25731):    at java.lang.Class.newInstance(Class.java:1409)
06-25 17:38:48.332: E/AndroidRuntime(25731):    at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
06-25 17:38:48.332: E/AndroidRuntime(25731):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1616)
06-25 17:38:48.332: E/AndroidRuntime(25731):    ... 20 more
4

1 回答 1

2

嗯,你的问题是这样的:

Java.lang.NumberFormatException: unable to parse 'window_animation_scale' as integer

解决这个问题,其余的应该符合要求。

于 2012-06-26T00:40:12.277 回答