InnerMapActivity.java 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. package com.usai.apex;
  2. import android.content.pm.PackageInfo;
  3. import android.content.pm.PackageManager.NameNotFoundException;
  4. import android.os.Bundle;
  5. import android.support.v4.app.Fragment;
  6. import android.support.v4.app.FragmentActivity;
  7. import android.support.v4.app.FragmentManager;
  8. import android.support.v4.app.FragmentTransaction;
  9. import android.view.KeyEvent;
  10. import com.baidu.mapapi.map.SupportMapFragment;
  11. //import com.baidu.mapapi.MKGeneralListener;
  12. //import com.baidu.mapapi.map.MKEvent;
  13. public class InnerMapActivity extends FragmentActivity
  14. {
  15. // public static boolean m_bKeyRight = true;
  16. // BMapManager mBMapManager = null;
  17. // public String strKey = getString(R.string.baidu_key);//"nqBQoSDbxrslhuzW91uViQX7";//release
  18. private static final String LTAG = "test";
  19. SupportMapFragment map;
  20. boolean m_bhasgoogleframework = true;
  21. // static class MyGeneralListener implements MKGeneralListener
  22. // {
  23. //
  24. // @Override
  25. // public void onGetNetworkState(int iError)
  26. // {
  27. // if (iError == MKEvent.ERROR_NETWORK_CONNECT)
  28. // {
  29. // Toast.makeText(
  30. // ApexTrackingApplication.get_instance()
  31. // .getApplicationContext(),
  32. // "????????????????????????", Toast.LENGTH_LONG).show();
  33. // }
  34. // else if (iError == MKEvent.ERROR_NETWORK_DATA)
  35. // {
  36. // Toast.makeText(
  37. // ApexTrackingApplication.get_instance()
  38. // .getApplicationContext(),
  39. // "??????????????????????????????", Toast.LENGTH_LONG)
  40. // .show();
  41. // }
  42. // // ...
  43. // }
  44. //
  45. // @Override
  46. // public void onGetPermissionState(int iError)
  47. // {
  48. // // ???????????????key???????????????
  49. // if (iError != 0)
  50. // {
  51. // // ??????Key?????????
  52. // Toast.makeText(
  53. // ApexTrackingApplication.get_instance()
  54. // .getApplicationContext(),
  55. // "?????? MyApplication.java???????????????????????????Key,??????????????????????????????????????????error: "
  56. // + iError, Toast.LENGTH_LONG).show();
  57. // m_bKeyRight = false;
  58. // }
  59. // else
  60. // {
  61. // m_bKeyRight = true;
  62. // Toast.makeText(
  63. // ApexTrackingApplication.get_instance()
  64. // .getApplicationContext(), "key????????????",
  65. // Toast.LENGTH_LONG).show();
  66. // }
  67. // }
  68. // }
  69. @Override
  70. public boolean onKeyDown(int keyCode, KeyEvent event)
  71. {
  72. if (keyCode == KeyEvent.KEYCODE_BACK)
  73. {
  74. // Intent myIntent = new Intent();
  75. // myIntent = new Intent(EditActivity.this, tabActivity.class);
  76. // startActivity(myIntent);
  77. finish();
  78. return true;
  79. }
  80. return super.onKeyDown(keyCode, event);
  81. }
  82. @Override
  83. protected void onCreate(Bundle savedInstanceState)
  84. {
  85. super.onCreate(savedInstanceState);
  86. PackageInfo packageInfo;
  87. try
  88. {
  89. packageInfo = this.getPackageManager().getPackageInfo(
  90. "com.google.android.gms", 0);
  91. }
  92. catch (NameNotFoundException e)
  93. {
  94. packageInfo = null;
  95. e.printStackTrace();
  96. }
  97. if (packageInfo == null)
  98. {
  99. m_bhasgoogleframework = false;
  100. System.out.println("没有安装");
  101. }
  102. else
  103. {
  104. m_bhasgoogleframework = true;
  105. System.out.println("已经安装");
  106. }
  107. // setUpMapIfNeeded();
  108. // m_bhasgoogleframework = false;
  109. m_bhasgoogleframework= true;
  110. Fragment slFragment = null;
  111. if (m_bhasgoogleframework )
  112. {
  113. setContentView(R.layout.activity_inner_map);
  114. slFragment = new ServiceLocationFragment();
  115. FragmentTransaction ft = getSupportFragmentManager()
  116. .beginTransaction();
  117. ft.replace(R.id.inner_map, slFragment);
  118. ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
  119. ft.addToBackStack("Location");
  120. ft.commit();
  121. }
  122. else
  123. {
  124. // if (mBMapManager == null)
  125. // {
  126. // mBMapManager = new BMapManager(getApplicationContext());
  127. // /**
  128. // * ??????BMapManager???????????????????????????BMapManager
  129. // */
  130. // mBMapManager.init(strKey, new MyGeneralListener());
  131. // }
  132. // f.initEngineManager(this);
  133. setContentView(R.layout.activity_inner_map);
  134. // Log.d(LTAG, "onCreate");
  135. // // setContentView(R.layout.activity_main);
  136. // map = SupportMapFragment.newInstance();
  137. BaiduMapFragment f = new BaiduMapFragment();
  138. FragmentManager manager = getSupportFragmentManager();
  139. manager.beginTransaction().add(R.id.inner_map, f, "map_fragment")
  140. .commit();
  141. }
  142. }
  143. // @Override
  144. // public boolean onCreateOptionsMenu(Menu menu)
  145. // {
  146. // // Inflate the menu; this adds items to the action bar if it is present.
  147. // getMenuInflater().inflate(R.menu.inner_map, menu);
  148. // return true;
  149. // }
  150. // private void setUpMapIfNeeded() {
  151. // // Do a null check to confirm that we have not already instantiated the
  152. // map.
  153. // if (mMap == null) {
  154. // // Try to obtain the map from the SupportMapFragment.
  155. // mMap = ((SupportMapFragment)
  156. // getSupportFragmentManager().findFragmentById(R.id.map))
  157. // .getMap();
  158. // // Check if we were successful in obtaining the map.
  159. // if (mMap != null) {
  160. // setUpMap();
  161. // }
  162. // }
  163. // }
  164. }