package com.example.myapplication08101;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;
import android.Manifest;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.telephony.TelephonyManager;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity {
TextView textview;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button btn1 = (Button) findViewById(R.id.button);
btn1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
openBaiduNavi();
}
});
}
private void openGaoDeNavi() {
StringBuffer stringBuffer = new StringBuffer("androidamap://navi?sourceApplication=")
.append("yitu8_driver").append("&lat=").append("34.264642646862")
.append("&lon=").append("108.95108518068")
.append("&dev=").append(1)
.append("&style=").append(0);
;
Intent intent = new Intent(Intent.ACTION_VIEW, android.net.Uri.parse(stringBuffer.toString()));
intent.addCategory(Intent.CATEGORY_DEFAULT);
intent.setPackage("com.autonavi.minimap");
startActivity(intent);
}
private void openBaiduNavi() {
StringBuffer stringBuffer = new StringBuffer("baidumap://map/navi?location=")
.append("28.680242").append(",").append("115.980541").append("&type=TIME");
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(stringBuffer.toString()));
intent.setPackage("com.baidu.BaiduMap");
startActivity(intent);
}
public String GetPhoneNum() {
TelephonyManager tm = (TelephonyManager) this.getSystemService(Context.TELEPHONY_SERVICE);
@SuppressLint("MissingPermission") String tel = tm.getLine1Number();
return tel;
}
}