lang
1package com.example.pointstrike; 2 3import android.app.Activity; 4import android.content.Intent; 5import android.os.Bundle; 6import android.view.Menu; 7import android.view.MenuItem; 8import android.view.View; 9import android.view.View.OnClickListener; 10import android.widget.Button; 11import android.widget.Toast; 12 13public class MainActivity extends Activity implements OnClickListener { 14 Button b; 15 @Override 16 protected void onCreate(Bundle savedInstanceState) { 17 super.onCreate(savedInstanceState); 18 setContentView(R.layout.activity_main); 19 b = (Button)findViewById(R.id.button1); 20 b.setOnClickListener(this); 21 } 22 23 @Override 24 public boolean onCreateOptionsMenu(Menu menu) { 25 // Inflate the menu; this adds items to the action bar if it is present. 26 getMenuInflater().inflate(R.menu.main, menu); 27 return true; 28 } 29 30 @Override 31 public boolean onOptionsItemSelected(MenuItem item) { 32 // Handle action bar item clicks here. The action bar will 33 // automatically handle clicks on the Home/Up button, so long 34 // as you specify a parent activity in AndroidManifest.xml. 35 int id = item.getItemId(); 36 if (id == R.id.action_settings) { 37 return true; 38 } 39 return super.onOptionsItemSelected(item); 40 } 41 ///////////////////////////////////////////////////////////////////////////////// 42 /// ↓OnlickListenerによって追加された処理↓ 43 ///////////////////////////////////////////////////////////////////////////// 44 @Override 45 public void onClick(View v) { 46 if(v == b){ 47 Intent intent = new Intent(this, game.class); 48 intent.setClassName("jp.game", "jp.sample.game"); 49 startActivity(intent); 50 //intent 51 //startActivity(intent);//★ 52 //インテント。アプリ間でメッセージのやり取りする仕組み 53 //SubActivityの情報を登録したインシデントを生成し、 54 //OSに「このインシデントやってみて」と投げかけている。 55 startActivityForResult(intent, 1);//★ 56 //↑移動先から情報を送り返してもらうことを期待する場合は、 57 //startActivity()ではなくstartActivityFoResult(,)を使う 58 //2番目の引数の1はリクエストコード。値に決まりはない。 59 } 60 } 61 62 //////////////////////////////////////////////////////////// 63 ////この画面に戻ってきたときに・・・ 64 //////////////////////////////////////////////////////////// 65 //起動先のインデントから戻ってきたときの処理 66 @Override 67 protected void onActivityResult 68 (int requestCode,int resultCode,Intent data) { 69 super.onActivityResult(requestCode, resultCode, data); 70 71 if(requestCode == 1&& resultCode == RESULT_OK){ 72 String messeage = data.getStringExtra("back"); 73 Toast.makeText(this, messeage, Toast.LENGTH_LONG).show(); 74 75 //Toast.makeText(this, "やっほー", Toast.LENGTH_LONG).show(); 76 } 77 //ここからマニュフェスト登録 78<?xml version="1.0" encoding="utf-8"?> 79<manifest xmlns:android="http://schemas.android.com/apk/res/android" 80 package="com.example.pointstrike" 81 android:versionCode="1" 82 android:versionName="1.0" > 83 84 <uses-sdk 85 android:minSdkVersion="15" 86 android:targetSdkVersion="15" /> 87 88 <application 89 android:allowBackup="true" 90 android:icon="@drawable/ic_launcher" 91 android:label="@string/app_name" 92 android:theme="@style/AppTheme" > 93 <activity 94 android:name=".MainActivity" 95 android:label="@string/app_name" > 96 <intent-filter> 97 <action android:name="android.intent.action.MAIN" /> 98 99 <category android:name="android.intent.category.LAUNCHER" /> 100 </intent-filter> 101 </activity> 102 <activity android:name=".game" 103 android:label="@string/app_name"></activity> 104 </application> 105 106</manifest> 107//ログキャット 10807-16 15:09:01.530: E/AndroidRuntime(1797): android.content.ActivityNotFoundException: Unable to find explicit activity class {jp.game/jp.sample.game}; have you declared this activity in your AndroidManifest.xml?
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。