どこの記事を参考にしたのでしょう、それとエラーログはどうなっていますか?
「Service」のコードを使い、アプリケーションで音楽を再生させたいです。
TestServiceActivityというActivityを作り、ネットで調べたコードを書きましたがエラーが出ます。
MainActivity.javaの方でもエラーが出ていて直し方がわかりません(;_;)
コード ``package jp.example.android.twoactivities; import android.app.Service; import android.content.Intent; import android.os.IBinder; import android.support.annotation.Nullable; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import java.security.Provider; public class TestServiceActivity extends Service { @Override public void onCreate() { super.onCreate(); } @Override public int OnStartCommand(Intent intent, int flags, int startId) { //to do something return START_NOT_STICKY; } @Override public void onDestroy() { super.onDestroy(); @Override public IBinder onBind(Intent intent) { return null; } } ※以下が、MainActivity.javaのエラーです(T ^ T) Intent intent = new Intent(getApplication(),TestServiceActivity.class); startService(intent); Intent intent = new Intent(getApplication(), TestService.class); // Serviceの停止 stopService(intent); stopSelf(); } private void stopSelf() { } }
あなたの回答
tips
プレビュー