2011-10-11 16 views
2

我已搜查這個問題了幾個小時...... 是否有可能我的應用程序中啓動谷歌地圖導航並顯示與它的一些信息,一個TextView?我必須創建一個應用程序,將目標地址傳遞給地圖導航,而導航工作時,將在應用程序底部顯示帶有汽車模型名稱的文本視圖。這是可行的嗎?Android應用程序與谷歌地圖導航和文本覆蓋

回答

1

是否可以在我的應用程序中啓動Google地圖導航,並顯示帶有一些信息的文本視圖?

你不能嵌入在你的其他應用程序,你可以不是你自己的小部件添加到一些其他的應用程序的UI。

+0

先生我想在Android應用中使用谷歌地圖導航,但無法找到任何API,除了意圖谷歌地圖應用程序。你有任何替代的「意圖谷歌地圖應用程序」使用谷歌地圖導航功能。 –

0

試試這個。

public class FloatingOverNewBooking extends Service { 

    private WindowManager windowManager; 
    private FrameLayout frameLayout; 
    private String str_ride_id; 
    public static final String BROADCAST_ACTION = "com.yourpackage.YourActivity"; 

    @Nullable 
    @Override 
    public IBinder onBind(Intent intent) { 
     return null; 
    } 

    @Override 
    public void onCreate() { 
     super.onCreate(); 
     timerLocation = new Timer(); 
     createFloatingBackButton(); 
    } 

    Timer timerLocation; 

    @Override 
    public int onStartCommand(Intent intent, int flags, int startId) { 
     // to receive any data from activity 
     str_ride_id = intent.getStringExtra("RIDE_ID"); 
     return START_STICKY; 
    } 

    @Override 
    public void onDestroy() { 
     super.onDestroy(); 
     if (frameLayout != null) { 
      //((WindowManager) getSystemService(WINDOW_SERVICE)).removeView(frameLayout); 

      windowManager.removeView(frameLayout); 
      frameLayout = null; 
     } 

     timerLocation.cancel(); 
    } 

    private void createFloatingBackButton() { 
     ClientLocatedActivity.isFloatingIconServiceAlive = true; 
     WindowManager.LayoutParams params = new WindowManager.LayoutParams(
       WindowManager.LayoutParams.WRAP_CONTENT, 
       WindowManager.LayoutParams.WRAP_CONTENT, 
       WindowManager.LayoutParams.TYPE_PHONE, 
       WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE, 
       PixelFormat.TRANSLUCENT); 
     WindowManager.LayoutParams windowManagerParams = new WindowManager.LayoutParams(WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY , 
       WindowManager.LayoutParams. FLAG_DIM_BEHIND, PixelFormat.TRANSLUCENT); 

     params.gravity = Gravity.LEFT | Gravity.CENTER_VERTICAL; 
     windowManager = (WindowManager) getSystemService(WINDOW_SERVICE); 
     frameLayout = new FrameLayout(this); 

     LayoutInflater layoutInflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE); 
     // Here is the place where you can inject whatever layout you want in the frame layout 
     layoutInflater.inflate(R.layout.share_new_booking_alert, frameLayout); 

     final TextView txtName = (TextView) frameLayout.findViewById(R.id.txtName); 
     Button backOnMap = (Button) frameLayout.findViewById(R.id.dialog_button); 

     if(!ObjectUtility.isNullOrEmpty(Config.Share.newPassenger)){ 
      txtName.setText(Config.Share.newPassenger.getUsername()); 
     } 


     backOnMap.setOnClickListener(new View.OnClickListener() { 
      @Override 
      public void onClick(View v) { 
       try { 

        ActivityManager am = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE); 
        am.killBackgroundProcesses("com.google.android.apps.maps"); 
        //MainActivity.getInstance().getShareRideDataById("go"); 
        FloatingOverNewBooking.this.stopSelf(); 
        ClientLocatedActivity.isFloatingIconServiceAlive = false; 
       } catch (Exception e) { 
        e.printStackTrace(); 
       } 
      } 
     }); 

     windowManager.addView(frameLayout, windowManagerParams); 
    } 
}