我試圖讓用戶按下一個按鈕,以便它會振動。所以我宣佈它在清單中,我爲它做了一個新的活動。繼承人一些代碼我錯了權限?我是否正確地將它包含在Manifest.xml中?
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="android.app"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="7" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:name=".AndroidActivity"
android:label="@string/app_name"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".activity2"
android:screenOrientation="portrait"
android:label="@string/app_name" >
</activity>
<activity android:name=".activity3"
android:screenOrientation="portrait"
android:label="@string/app_name" >
</activity>
<activity android:name=".next" >
</activity>
<uses-permission android:name="android.permission.VIBRATE"/>
</application>
</manifest>
和繼承人按鈕的活動:
package android.app;
import android.app.R;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
public class AndroidVibrator extends Activity {
protected void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.main3);
final Button button = (Button) findViewById(R.id.sound);
button.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// Perform action on click
}
});
}
}