1

現在のステータス: 問題はまだ解決されていません - ヘルプが必要です..

私は現在、新しいGoogleマップAndroid v2を使用してマップアプリを開発しています..実際のアプリに適用する前に..テストを行い、動作させようとしました..Google Developersのドキュメントに従いました

しかし、私が見逃した部分があるようですが、それらを見つけることができませんでした..私のためにそれらを特定できますか? 以下にソースコードを示します...それらをはっきりと見てもらうために..

ここに私の現在のMainActivityクラス(更新):<---プログラムにはこのクラスしかありません

    package com.madcatworld.demomapv2;

    import com.google.android.gms.maps.SupportMapFragment;

    import android.os.Bundle;
    import android.support.v4.app.FragmentActivity;
    import android.view.Menu;

    public class MainActivity extends FragmentActivity {

        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);

        SupportMapFragment fragment = new SupportMapFragment();
        getSupportFragmentManager().beginTransaction()
                .add(R.id.map, fragment).commit();  

        }

        @Override
        public boolean onCreateOptionsMenu(Menu menu) {
            // Inflate the menu; this adds items to the action bar if it is present.
            getMenuInflater().inflate(R.menu.activity_main, menu);
            return true;
        }

    }

ここに私の activity_main.xml があります: (更新)

<?xml version="1.0" encoding="utf-8"?>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/map"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    class="com.google.android.gms.maps.SupportMapFragment" />

ここに私のManifest.xmlがあります:

 <?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
        package="com.madcatworld.demomapv2"
        android:versionCode="1"
        android:versionName="1.0" >

        <uses-feature
            android:glEsVersion="0x00020000"
            android:required="true" />

        <uses-sdk
            android:minSdkVersion="8"
            android:targetSdkVersion="14" />

        <permission
            android:name="com.madcatworld.demomapv2.permission.MAPS_RECEIVE"
            android:protectionLevel="signature" />

        <uses-permission android:name="com.madcatworld.demomapv2.permission.MAPS_RECEIVE" />
        <uses-permission android:name="android.permission.INTERNET" />
        <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
        <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
        <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
        <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />

        <application
            android:allowBackup="true"
            android:icon="@drawable/ic_launcher"
            android:label="@string/app_name"
            android:theme="@style/AppTheme" >
            <meta-data
                android:name="com.google.android.maps.v2.API_KEY"
                android:value="xxxxxxxxxxxxxxx" />

            <activity
                android:name="com.madcatworld.demomapv2.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>
        </application>

    </manifest>

私のエミュレーター:「Get Google Play Services」ダイアログが表示されます..クリックすると...以下のようにいくつかのエラーが発生します..

私の現在のエラーログ(更新)は、以前のエラーよりも短いようです!! :) :

01-25 04:23:18.647: E/AndroidRuntime(503): FATAL EXCEPTION: main
01-25 04:23:18.647: E/AndroidRuntime(503): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=http://play.google.com/store/apps/details?id=com.google.android.gms flg=0x80000 pkg=com.android.vending }
01-25 04:23:18.647: E/AndroidRuntime(503):  at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1408)
01-25 04:23:18.647: E/AndroidRuntime(503):  at android.app.Instrumentation.execStartActivity(Instrumentation.java:1378)
01-25 04:23:18.647: E/AndroidRuntime(503):  at android.app.Activity.startActivityForResult(Activity.java:2817)
01-25 04:23:18.647: E/AndroidRuntime(503):  at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:817)
01-25 04:23:18.647: E/AndroidRuntime(503):  at android.app.Activity.startActivity(Activity.java:2923)
01-25 04:23:18.647: E/AndroidRuntime(503):  at com.google.android.gms.internal.d$2.onClick(Unknown Source)
01-25 04:23:18.647: E/AndroidRuntime(503):  at android.view.View.performClick(View.java:2408)
01-25 04:23:18.647: E/AndroidRuntime(503):  at android.view.View$PerformClick.run(View.java:8816)
01-25 04:23:18.647: E/AndroidRuntime(503):  at android.os.Handler.handleCallback(Handler.java:587)
01-25 04:23:18.647: E/AndroidRuntime(503):  at android.os.Handler.dispatchMessage(Handler.java:92)
01-25 04:23:18.647: E/AndroidRuntime(503):  at android.os.Looper.loop(Looper.java:123)
01-25 04:23:18.647: E/AndroidRuntime(503):  at android.app.ActivityThread.main(ActivityThread.java:4627)
01-25 04:23:18.647: E/AndroidRuntime(503):  at java.lang.reflect.Method.invokeNative(Native Method)
01-25 04:23:18.647: E/AndroidRuntime(503):  at java.lang.reflect.Method.invoke(Method.java:521)
01-25 04:23:18.647: E/AndroidRuntime(503):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
01-25 04:23:18.647: E/AndroidRuntime(503):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
01-25 04:23:18.647: E/AndroidRuntime(503):  at dalvik.system.NativeStart.main(Native Method)

ご参考までに、

  1. Eclipse から SHAI num をコピーして、Google アカウントに新しい API キーを既に生成しています。

  2. この手順を実行しました Android Tools> rightclick> Export Signed Application Packages (それらを相互にリンクさせるために、新しいキーストアを作成します) 私の質問は: これを実装する必要があります (いいえ 2)??

私が犯した間違いを見つけたら教えてください..ありがとう

4

2 に答える 2

0

commit()メソッドを使用する代わりに.getMap();、マップを取得してロードします。

GoogleMap mMap;
  mMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map))
                .getMap();
于 2013-01-25T04:16:34.583 に答える
0

ファイル Mapfragment idandroid.R.id.contentのどこにアクセスしようとしているかを間違えましたmy activity_main.xmlandroid:id="@+id/map"

では、この方法を試してみてください。

このコードを onCreate(..) メソッドに入れます

SupportMapFragment fragment = new SupportMapFragment();
    getSupportFragmentManager().beginTransaction()
            .add(R.id.map, fragment).commit();

これの代わりに。

  SupportMapFragment fragment = new SupportMapFragment();
        getSupportFragmentManager().beginTransaction()
                .add(android.R.id.content, fragment).commit();
于 2013-01-25T03:47:57.500 に答える