启动活动的应用程序

时间:2012-10-20 08:38:04

标签: java android

  

可能重复:
  App just for launching an activity

我正在尝试添加一个快捷方式,在App Drawer(不是主屏幕)上启动录音机

所以app应该是空的,它唯一需要做的就是启动录音机 com.android.soundrecorder / com.android.soundrecorder.SoundRecorder

我该怎么做?

我得到Force Stop:

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

}
}

0 个答案:

没有答案