地图活动的意图问题 - 如何解决?

我需要创建一个必须在下周通过的活动。活动是用 2 个按钮(相机和地图)制作一个主页,这意味着我必须使用意图功能来工作这个应用程序。但是我有一个问题,相机按钮可以正常工作,但我的地图无法正常工作,这就是我在这里寻求帮助的原因。


我试过地图=


(Button) findViewById(R.id.map);

        map.setOnClickListener(new View.OnClickListener() {

            @Override

            public void onClick(View v)

            { openMapsActivity();

            }

        });

然后


p


ublic void openMapsActivity() {


        Intent intent = new Intent(this, MapsActivity.class);


        startActivity(intent);


    }


开心每一天1111
浏览 123回答 1
1回答

呼唤远方

像这样更新您的清单应用程序:<application&nbsp; &nbsp; android:allowBackup="true"&nbsp; &nbsp; android:icon="@mipmap/ic_launcher"&nbsp; &nbsp; android:label="@string/app_name"&nbsp; &nbsp; android:roundIcon="@mipmap/ic_launcher_round"&nbsp; &nbsp; android:supportsRtl="true"&nbsp; &nbsp; android:theme="@style/AppTheme">&nbsp; &nbsp; <!--&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;The API key for Google Maps-based APIs is defined as a string resource.&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;(See the file "res/values/google_maps_api.xml").&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Note that the API key is linked to the encryption key used to sign the APK.&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;You need a different API key for each encryption key, including the release key that is used to&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sign the APK for publishing.&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;You can define the keys for the debug and release targets in src/debug/ and src/release/.&nbsp; &nbsp; -->&nbsp; &nbsp; <meta-data&nbsp; &nbsp; &nbsp; &nbsp; android:name="com.google.android.geo.API_KEY"&nbsp; &nbsp; &nbsp; &nbsp; android:value="@string/google_maps_key" />&nbsp; &nbsp; <activity&nbsp; &nbsp; &nbsp; &nbsp; android:name=".MainActivity"&nbsp; &nbsp; &nbsp; &nbsp; android:label="@string/title_activity_maps">&nbsp; &nbsp; &nbsp; &nbsp; <intent-filter>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <action android:name="android.intent.action.MAIN" />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <category android:name="android.intent.category.LAUNCHER" />&nbsp; &nbsp; &nbsp; &nbsp; </intent-filter>&nbsp; &nbsp; </activity>&nbsp; &nbsp;<activity&nbsp; &nbsp; &nbsp; &nbsp; android:name=".MapsActivity"&nbsp; &nbsp; &nbsp; &nbsp; android:screenOrientation="portrait" /></application>
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java