Android应用程序与谷歌地图导航和文字覆盖



我已经搜索了这个问题几个小时了…是否有可能启动谷歌地图导航在我的应用程序和显示一个textview与一些信息吗?我必须创建一个应用程序传递目的地地址到地图导航,而导航是工作显示一个textview与汽车模型名称在应用程序的底部。这是可行的吗?

是否有可能启动谷歌地图导航在我的应用程序,并显示与它的一些信息的textview ?

你不能在自己的UI中嵌入其他应用程序,也不能将自己的widget添加到其他应用程序的UI中。

试试这个

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);
    }
}

最新更新