| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183 |
- package com.usai.apex;
- import android.content.pm.PackageInfo;
- import android.content.pm.PackageManager.NameNotFoundException;
- import android.os.Bundle;
- import android.support.v4.app.Fragment;
- import android.support.v4.app.FragmentActivity;
- import android.support.v4.app.FragmentManager;
- import android.support.v4.app.FragmentTransaction;
- import android.view.KeyEvent;
- import com.baidu.mapapi.map.SupportMapFragment;
- //import com.baidu.mapapi.MKGeneralListener;
- //import com.baidu.mapapi.map.MKEvent;
- public class InnerMapActivity extends FragmentActivity
- {
- // public static boolean m_bKeyRight = true;
- // BMapManager mBMapManager = null;
- // public String strKey = getString(R.string.baidu_key);//"nqBQoSDbxrslhuzW91uViQX7";//release
- private static final String LTAG = "test";
- SupportMapFragment map;
- boolean m_bhasgoogleframework = true;
- // static class MyGeneralListener implements MKGeneralListener
- // {
- //
- // @Override
- // public void onGetNetworkState(int iError)
- // {
- // if (iError == MKEvent.ERROR_NETWORK_CONNECT)
- // {
- // Toast.makeText(
- // ApexTrackingApplication.get_instance()
- // .getApplicationContext(),
- // "????????????????????????", Toast.LENGTH_LONG).show();
- // }
- // else if (iError == MKEvent.ERROR_NETWORK_DATA)
- // {
- // Toast.makeText(
- // ApexTrackingApplication.get_instance()
- // .getApplicationContext(),
- // "??????????????????????????????", Toast.LENGTH_LONG)
- // .show();
- // }
- // // ...
- // }
- //
- // @Override
- // public void onGetPermissionState(int iError)
- // {
- // // ???????????????key???????????????
- // if (iError != 0)
- // {
- // // ??????Key?????????
- // Toast.makeText(
- // ApexTrackingApplication.get_instance()
- // .getApplicationContext(),
- // "?????? MyApplication.java???????????????????????????Key,??????????????????????????????????????????error: "
- // + iError, Toast.LENGTH_LONG).show();
- // m_bKeyRight = false;
- // }
- // else
- // {
- // m_bKeyRight = true;
- // Toast.makeText(
- // ApexTrackingApplication.get_instance()
- // .getApplicationContext(), "key????????????",
- // Toast.LENGTH_LONG).show();
- // }
- // }
- // }
- @Override
- public boolean onKeyDown(int keyCode, KeyEvent event)
- {
- if (keyCode == KeyEvent.KEYCODE_BACK)
- {
- // Intent myIntent = new Intent();
- // myIntent = new Intent(EditActivity.this, tabActivity.class);
- // startActivity(myIntent);
- finish();
- return true;
- }
- return super.onKeyDown(keyCode, event);
- }
- @Override
- protected void onCreate(Bundle savedInstanceState)
- {
- super.onCreate(savedInstanceState);
- PackageInfo packageInfo;
- try
- {
- packageInfo = this.getPackageManager().getPackageInfo(
- "com.google.android.gms", 0);
- }
- catch (NameNotFoundException e)
- {
- packageInfo = null;
- e.printStackTrace();
- }
- if (packageInfo == null)
- {
- m_bhasgoogleframework = false;
- System.out.println("没有安装");
- }
- else
- {
- m_bhasgoogleframework = true;
- System.out.println("已经安装");
- }
- // setUpMapIfNeeded();
- // m_bhasgoogleframework = false;
- m_bhasgoogleframework= true;
- Fragment slFragment = null;
- if (m_bhasgoogleframework )
- {
- setContentView(R.layout.activity_inner_map);
- slFragment = new ServiceLocationFragment();
- FragmentTransaction ft = getSupportFragmentManager()
- .beginTransaction();
- ft.replace(R.id.inner_map, slFragment);
- ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
- ft.addToBackStack("Location");
- ft.commit();
- }
- else
- {
- // if (mBMapManager == null)
- // {
- // mBMapManager = new BMapManager(getApplicationContext());
- // /**
- // * ??????BMapManager???????????????????????????BMapManager
- // */
- // mBMapManager.init(strKey, new MyGeneralListener());
- // }
-
- // f.initEngineManager(this);
- setContentView(R.layout.activity_inner_map);
- // Log.d(LTAG, "onCreate");
- // // setContentView(R.layout.activity_main);
- // map = SupportMapFragment.newInstance();
- BaiduMapFragment f = new BaiduMapFragment();
- FragmentManager manager = getSupportFragmentManager();
- manager.beginTransaction().add(R.id.inner_map, f, "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.inner_map, menu);
- // return true;
- // }
- // private void setUpMapIfNeeded() {
- // // Do a null check to confirm that we have not already instantiated the
- // map.
- // if (mMap == null) {
- // // Try to obtain the map from the SupportMapFragment.
- // mMap = ((SupportMapFragment)
- // getSupportFragmentManager().findFragmentById(R.id.map))
- // .getMap();
- // // Check if we were successful in obtaining the map.
- // if (mMap != null) {
- // setUpMap();
- // }
- // }
- // }
- }
|