Lonction说明

 

1, 基于百度地图API开发,用于实现地理位置选取,发送,展示,与消息编辑界面切入点有两处,代码如下:

case R.id.menuitem_location_share:

// Begin : add by qiang.liu 2013-12-9 for multi send from contact

if (ensureMultiRecipient()) {

Toast.makeText(getApplicationContext(), R.string.confirm_send_multi_audio, Toast.LENGTH_SHORT).show();

return;

}

// End : add by qiang.liu 2013-12-9 for multi send from contact

//Begin: add by liuxue 2013-11-26

if (mNetWorkStatus) {

if (!rcsIsConnected()) {

Toast.makeText(ComposeMessageActivity.this,

strNetworkUnavailable, Toast.LENGTH_SHORT).show();

return;

}

}

//End: add by liuxue 2013-11-26

if (isRecipientsEditorVisible()

&& TextUtils.isEmpty(mRecipientsEditor.getText())) {

showToastNoContacts();

return;

}

//yexiaoyan 20131224 change begin

if(!isRcs){

Toast.makeText(getApplicationContext(), R.string.msg_tost_notRcs, Toast.LENGTH_SHORT).show();

return;

}

//yexiaoyan 20131224 change end

// zhangmeie 20131224 change begin

Intent intent = new Intent(ComposeMessageActivity.this,LocationActivity.class);

intent.putExtra(LocationActivity.MESSAGE_TYPE,LocationActivity.LOCATION_EDITOR);

startActivityForResult(intent, REQUEST_CODE_LOCATION_MESSAGE);

获得经,纬度,地理位置后返回到消息编辑界面切入点如下:

caseREQUEST_CODE_LOCATION_MESSAGE: {

if (sendByRCS

&& mConversation != null

&& aService != null

&& ensureCapabilityRcs(formatNumber(mConversation.getRecipients().get(0).getNumber()))

&& rcsIsConnected()) {

if (mNetWorkStatus) {

Bundle bundle = (Bundle)data.getExtras();

double lat =bundle.getDouble(LocationActivity.MESSAGE_LAT);

double lng =bundle.getDouble(LocationActivity.MESSAGE_LNG);

String mAddress =bundle.getString(LocationActivity.MESSAGE_ADDRESS);

try {

aService.sendLocation(getSingleRecipientNumber(), lat,lng, mAddress, "");

} catch (Exception ex) {

ex.printStackTrace();

}

 

mConversation.ensureThreadId();

onMessageSent();

} else {

String message = getString(R.string.network_not_ready);

Toast.makeText(ComposeMessageActivity.this, message, Toast.LENGTH_SHORT)

.show();

}

}

break;

 

 

2, 主要类文件有:

com.android.mms.ui.LocationActivity.java

com.android.mms.ui.LocationMapView.java

com.android.mms.ui.MyBaiduLotion.java

 

LocationActivity是地理位置选择或详情,若处于选择状态,地图中心位置为手机持有者地理位置,可拖动地图选择目标位置,点击发送按钮,发送位置给接收端;若处于详情状态,中心位置通过选择位置消息经纬度位置,拖动不可再选择位置,发送按钮不可见.

LocationMapView继承百度地图MapView,新增OnMapViewChangedListener借口,拖动地图调用重写onTouchEvent方法触发OnMapViewChangedListener监听,LocationActivity类实现的OnMapViewChangedListener,获得经纬度,及时更新选中地理位置

MyBaiduLotion主要是通过经纬度逆解析出地理位置

 

3, 然后必须在配置文件注册百度服务

<service

android:name="com.baidu.location.f"

android:enabled="true"

android:process=":remote">

<intent-filter>

<actionandroid:name="com.baidu.location.service_v3.3" >

</action>

</intent-filter>

</service>

 

 

4, 独立的百度地图 privatestaticfinal String key = "xxxxxxxxxxxxxxxxxxxx";

5,关于jarso,Mms/src/libs文件夹下,导入baidumapapi_v2_3_1.jar,locSDK_3.3.jar,armeabi文件夹(包括libBaiduMapSDK_v2_3_1.soliblocSDK3.so),若要在源码里面编译必须在Mms/Android.mk加入jar配置信息

....................

LOCAL_STATIC_JAVA_LIBRARIES += liblocsdk

 

LOCAL_STATIC_JAVA_LIBRARIES += liblocbaidusdk

........................

include $(CLEAR_VARS)

 

 

................

LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES := liblocsdk:libs/locSDK_3.3.jar

 

LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES := liblocbaidusdk:libs/baidumapapi_v2_3_1.jar

 

 

..................

include $(BUILD_MULTI_PREBUILT)

...................

注意若要在源码编译必须在Mms/proguard.flags文件中导入百度架包,如下:

-keep class com.baidu.** {



*;

 

}

 

-keep class vi.com.gdi.bgl.android.**{

 

*;

 

}

 

你可能感兴趣的:(IO)