Android 용 뮤직 플레이어를 만들고 있습니다. 내가 시도하고있는 것은 앱이 실행되고 사용자가 목록 항목을 클릭 할 때 재생 목록 을 보여 주며 노래를 재생하는 android_player 활동에 인 텐트가 전달됩니다. 하지만 작동하지 않으며 목록 항목 앱을 클릭하면 충돌이 발생하고 닫힙니다.Android 액티비티는 기본 및 런처 활동으로 선언 된 경우에만 작동합니다.
하지만 나는 music_player 활동을 실행 프로그램으로 선언 할 때 작동합니다. 하지만 먼저 음악 재생 목록이 아닌 재생 목록을 표시하고 싶습니다.
내가 매니페스트 파일을 다음 한
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.app"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MainActivity"
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=".AndroidMusicPlayerActivity"
android:label="@string/app_name"
android:configChanges="keyboardHidden|orientation"
android:screenOrientation="portrait">
<-- <intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter> -->
</activity>
</application>
내가 그것을 작동하도록 내 매니페스트 파일을 확인해야합니다 변경됩니다. 재생 목록을 보여줍니다
AndroidMusicPlayerActivity has following code to receive intent
@Override
protected void onActivityResult(int requestCode,
int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if(resultCode == 100){
currentSongIndex = data.getExtras().getInt("songIndex");
// play selected song
playSong(currentSongIndex);
}
}
MainActivity 난을 listitem를 클릭하면, 의도
lv.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
// getting listItem index
int songIndex = position;
// Starting new intent
Intent in = new Intent(getApplicationContext(),
AndroidMusicPlayerActivity.class);
// Sending songIndex to PlayerActivity
in.putExtra("songIndex", songIndex);
setResult(100, in);
// Closing PlayListView
finish();
}
});
로그 고양이 데이터를 다음 전달합니다.
04-30 16:17:16.946: D/OpenGLRenderer(3858): Enabling debug mode 0 04-30
16:17:29.958: W/IInputConnectionWrapper(3858): showStatusIcon on inactive InputConnection
04-30 16:17:30.018: D/OpenGLRenderer(3858): Flushing caches (mode 0)
이 코드가 작동하도록 변경해야하는 사항은 무엇입니까? 나는 안드로이드를 처음 사용합니다. 도와주세요. 감사합니다.
"충돌이 발생하고 닫힙니다."-> logcat을 게시하고 스 니펫에서 어떤 행이 참조되는지 가리 킵니다. –
logcat 및 java 코드도 함께 게시하십시오. –
@Class Stacker가 LogCat 데이터를 추가했습니다. – StarWars