2016-04-14 9 views
0

にデータを送信し、私はいくつかの緯度と私はMapActivityにこれらを送りたいlogtituteを持っていることは、私は多くの方法をしましたが、そうMapacitivityMapActivity

protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.activity_maps); 

    Intent intent = getIntent(); 
    HashMap<String, String> hashMap = (HashMap<String, String>)intent.getSerializableExtra("map"); 
    Log.v("HashMapTest", hashMap.get("key")); 
    // Obtain the SupportMapFragment and get notified when the map is ready to be used. 
    SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager() 
      .findFragmentById(R.id.map); 
    mapFragment.getMapAsync(this); 
+0

問題は何ですか?それは動作していないのですか?例外はありますか? –

+0

可能な複製:http://stackoverflow.com/questions/7578236/how-to-send-hashmap-value-to-another-activity-using-an-intent – dex

答えて

1

public void setdaata(View view){ 
    HashMap<String, String> hashMap = new HashMap<String, String>(); 
    hashMap.put("key", "value"); 
    Intent intent = new Intent(this, MapsActivity.class); 
    intent.putExtra("map", item); 
    startActivity(intent); 




} 

と受信コードをfailled可能ですおそらくあなたは、2つの単純な値を送信するために、ここでマップは必要ありません。

はこれを試してみてください:

を次に、あなたの値を抽出するために

:必要に応じて

Intent intent = getIntent(); 

double mLongitude = intent.getExtras().getDouble("longitude); 
double mLatitude = intent.getExtras().getDouble("latitude"); 

今、あなたは自分の価値観を持っている必要があります!

私はこれがあなたを助けてくれることを願っています!

+0

先生、私は受け取った値の多くを持っていますjsonこの方法私はちょうど2値の仕事は、MApactivityに配列を送信する方法があると思う –

+0

ここで最善のアプローチは、ローカルデータベースにあなたのデータを格納し、単に次の活動に移動し、データをユーザに送信する。それは私がやることです – Eenvincible

関連する問題