android之通过intent跳转到地图项
来源:互联网 发布:360数据恢复大师好用吗 编辑:程序博客网 时间:2024/06/06 11:04
首先:对main.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/LinearLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".ActivityMain" >
<!--
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world" />
-->
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="show the map!!!"
/>
<!-- 需注意 -->
<com.google.android.maps.MapView
android:id="@+id/myMapView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:clickable="true"
android:apiKey="c4579586f41a90372f762cb65c78be5d"
/>
</LinearLayout>
对ActivityMain.java 注意直接继承的类
package com.myexample.intent0409;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import com.google.android.maps.MapActivity;
//找到这个合适的继承关系
public class ActivityMain extends MapActivity {
Button button;
OnClickListener listener;
Uri uri = Uri.parse("geo:38.69,118.50");
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// setContentView(R.layout.main);
//
// button = (Button) findViewById(R.id.button);
listener = new OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(intent);
}
};
setContentView(R.layout.main);
button = (Button) findViewById(R.id.button);
button.setOnClickListener(listener); // 这个整体的使用情况
}
//需要实现这个方法是主要问题
@Override
protected boolean isRouteDisplayed() {
return false;
}
// @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;
// }
}
另外,需要对manifest的内容做一定的修改
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.myexample.intent0409"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<!-- 这个权限是需要加入的。。 -->
<uses-permission android:name="android.permission.INTERNET"/>
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.myexample.intent0409.ActivityMain"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<!-- 注意添加的以下的语句 -->
</intent-filter>
<intent-filter android:priority="0">
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<data android:scheme="geo"/>
</intent-filter>
</activity>
<uses-library android:name="com.google.android.maps"/>
</application>
</manifest>
地图的功能还待后续继续实现。。。
- android之通过intent跳转到地图项
- android通过Intent跳转到添加联系人界面的小结
- Android之使用Intent跳转到一个网页
- 通过Intent跳转到系统应用
- 通过intent跳转到系统拨号页面
- android跳转到地图app
- android应用程序跳转到系统的各个设置页面和通过Intent action 跳转到系统页面,
- android Intent 实现跳转 通过注册表
- android 通过Intent action 跳转到系统页面,调用系统功能以及action动...
- android 通过Intent action 跳转到系统页面,调用系统功能以及action动...
- android 通过Intent action 跳转到系统页面,调用系统功能以及action动作
- android 通过Intent action 跳转到系统页面,调用系统功能以及action动作
- Android 自定义切换卡功能,通过intent跳转到添加内容页面
- Android Intent跳转第三方地图导航大全
- Android 跳转到网页 地图 拨号程序
- Android开发之Intent跳转到系统应用中的拨号界面、联系人界面、短信界面
- Android开发之Intent跳转到系统应用中的拨号界面、联系人界面、短信界面
- Android开发之Intent跳转到系统应用中的拨号界面、联系人界面、短信界面
- Jquery Ajax 请求
- C++之get、getline、cin.getlin
- Eclipse快捷键大全
- 虚函数与纯虚函数
- winForm自动更新
- android之通过intent跳转到地图项
- 一种简单无锁队列的实现
- JasperReports Server on Cloud Foundry
- 重学C++ 005分离接口与实现
- js中将字符串转换成json--(//highcharts图表里data数据源必须是数组形势的[{name="test1"},{name="test2"}])
- struts2 总结
- c 函数fopen,fwrite,fread,fgets,fputs
- 关于 Spring3 报org.aopalliance.intercept.MethodInterceptor问题解决方法
- 设计模式(不懂)