-3

所以我有这个活动:

public class settings_dock extends Activity {

    AlertDialog alert;


    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.settings); 


        //Weather settings
        ListView listView = (ListView) findViewById(R.id.settings);
        String[] values = new String[] { "Enable/Disable","Configure Item 1","Configure Item 2","Configure Item 3","Configure Item 4"};




        ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
                android.R.layout.simple_list_item_1, android.R.id.text1, values);

            // Assign adapter to ListView
            listView.setAdapter(adapter);

        listView.setOnItemClickListener(new OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view,
                int position, long id) {
                if(position == 0)
                {

                    final CharSequence[] items = {"Enabled", "Disabled"};

                    AlertDialog.Builder builder = new AlertDialog.Builder(settings_dock.this);
                    builder.setTitle("The Dock is ....");



                    SharedPreferences dock = app.getContext().getSharedPreferences("dock",app.getContext().MODE_WORLD_READABLE);

                    builder.setSingleChoiceItems(items,dock.getInt("enabled_disabled",-1), new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int item) {

                            SharedPreferences dock = app.getContext().getSharedPreferences("dock",app.getContext().MODE_WORLD_READABLE);
                             SharedPreferences.Editor prefsEditor = dock.edit();
                             prefsEditor.putInt("enabled_disabled",item);
                             prefsEditor.commit();
                             alert.dismiss();
                             if(item == 0)
                             {

                             }
                            if(item == 1)
                                {

                                }


                        }
                    });
                    alert = builder.create();
                    alert.show();
                }
                if(position == 1)
                {
                    Intent in=new Intent(settings_dock.this,set_dock.class);
                    in.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                    in.putExtra("dock_location",1);

                }
                if(position == 2)
                {
                    Intent in=new Intent(settings_dock.this,set_dock.class);
                    in.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                    in.putExtra("dock_location",2);
                }
                if(position == 3)
                {
                    Intent in=new Intent(settings_dock.this,set_dock.class);
                    in.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                    in.putExtra("dock_location",3);
                }
                if(position == 4)
                {
                    Intent in=new Intent(settings_dock.this,set_dock.class);
                    in.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                    in.putExtra("dock_location",4);
                }


            }
        });
    }

}

并且我正在尝试启动一个意图,如您所见,但是 simplay 没有任何反应,甚至 logcat 中都没有错误启动的意图在我的清单中被渴望

我现在真的很困惑:(

编辑: 清单:

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

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

    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
    <uses-permission android:name="android.permission.DISABLE_KEYGUARD"/>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
    <uses-permission android:name="android.permission.INTERNET"/>


    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name" >

        <activity
            android:name=".app"
            android:label="@string/app_name"
            android:screenOrientation="portrait"
            android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
            android:excludeFromRecents="true"
            android:clearTaskOnLaunch="true"> 
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <receiver android:name="boot">
            <intent-filter>
                <action android:name="android.intent.action.BOOT_COMPLETED"/>
                <category android:name="android.intent.category.HOME" />
            </intent-filter>
        </receiver>

        <service
        android:name="lockservice" 
        android:process=":lockscreen" 
        android:icon="@drawable/ic_launcher"
        android:label="Lockscreen">
        </service>

        <activity
            android:name=".weather_update"
            android:theme="@android:style/Theme.Translucent">

        </activity>
        <activity
            android:name=".restart_service"
            android:theme="@android:style/Theme.Translucent">

        </activity>
        <activity
            android:name=".settings">

        </activity>
        <activity
            android:name=".settings_weather">

        </activity>
        <activity
            android:name=".settings_general">

        </activity>
        <activity
            android:name=".settings_dock">

        </activity>
        <activity
            android:name=".settings_personalisation">

        </activity>
        <activity
            android:name=".set_dock"
            android:theme="@android:style/Theme.Dialog"
            android:screenOrientation="portrait">

        </activity>

    </application>

</manifest>
4

2 回答 2

2

你没有打电话:

startActivity(in);

希望这会有所帮助。

于 2012-06-09T10:29:06.437 回答
0

尝试添加startActivity(in)每个if语句。要开始一项活动,您需要调用startActivity(intent)方法。

于 2012-06-09T10:29:43.610 回答