可能重复:
仅用于启动活动的应用程序
我正在尝试添加快捷方式以在 App Drawer(不是主屏幕)上启动录音机
所以应用程序应该是空的,它唯一要做的就是启动 Sound Recorder com.android.soundrecorder/com.android.soundrecorder.SoundRecorder
我怎样才能做到这一点?
我得到了强制停止:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="recorder.audio.dsaif"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="16"
android:targetSdkVersion="15" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".Recorder"
android:label="@string/title_activity_recorder" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
和java文件
package recorder.audio.dsaif;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
public class Recorder extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Intent LaunchIntent = getPackageManager().getLaunchIntentForPackage("com.android.soundrecorder.SoundRecorder");
startActivity(LaunchIntent);
setContentView(R.layout.activity_recorder);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_recorder, menu);
return true;
}
}