如何使用 GPS 在 Android 中获取我的当前位置?

2023-12-01

我想通过 GPS 以地址形式获取我当前的位置。我正在使用android studio。 它说我的应用程序停止工作。 其中有什么错误呢? 有人可以帮我摆脱这个困境吗?

我在 Activity_main.xml 文件中的代码是

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout 
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">

<TextView
    android:id="@+id/text_view"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Hello World!"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toRightOf="parent"
    app:layout_constraintTop_toTopOf="parent" />

我在 MainActivity.java 中的代码是

package com.example.showlatlong;

import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;

import android.Manifest;
import android.content.Context;
import android.content.pm.PackageManager;
import android.location.Address;
import android.location.Geocoder;
import android.location.Location;
import android.location.LocationManager;
import android.os.Bundle;
import android.widget.TextView;

import java.util.List;
import java.util.Locale;

public class MainActivity extends AppCompatActivity {

Location gps_loc, network_loc, final_loc;
double longitude;
double latitude;
String userCountry, userAddress;


@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    TextView tv = findViewById(R.id.text_view);

    LocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);


    if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED
            && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED
            && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_NETWORK_STATE) != PackageManager.PERMISSION_GRANTED) {

        return;
    }

    try {
        gps_loc = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
        network_loc = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
    } catch (Exception e) {
        e.printStackTrace();
    }

    if (gps_loc != null) {
        final_loc = gps_loc;
        latitude = final_loc.getLatitude();
        longitude = final_loc.getLongitude();
    }
    else if (network_loc != null) {
        final_loc = network_loc;
        latitude = final_loc.getLatitude();
        longitude = final_loc.getLongitude();
    }
    else {
        latitude = 0.0;
        longitude = 0.0;
    }

     ActivityCompat.requestPermissions(this, new String[] {Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_NETWORK_STATE}, 1);



    try {

        Geocoder geocoder = new Geocoder(this, Locale.getDefault());
        List<Address> addresses = geocoder.getFromLocation(latitude, longitude, 1);
        if (addresses != null && addresses.size() > 0) {
            userCountry = addresses.get(0).getCountryName();
            userAddress = addresses.get(0).getAddressLine(0);
            tv.setText(userCountry + ", " + userAddress);
        }
        else {
            userCountry = "Unknown";
            tv.setText(userCountry);
        }

    } catch (Exception e) {
        e.printStackTrace();
    }

}

}

我在manifest.xml中的代码是

<?xml version="1.0" encoding="utf-8"?>

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:roundIcon="@mipmap/ic_launcher_round"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">
    <activity android:name=".MainActivity">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>

整个代码是这样的。它正在打开应用程序,不到一秒钟,它就会通过在我的 Android 应用程序上抛出“应用程序不断停止”的错误消息来关闭。 这是我在 logcat 中得到的

2019-09-11 12:58:45.344 15400-15400/com.example.showlatlong E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.showlatlong, PID: 15400
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.showlatlong/com.example.showlatlong.MainActivity}: android.view.InflateException: Binary XML file line #2: Binary XML file line #2: Error inflating class android.support.constraint.ConstraintLayout
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2723)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2784)
    at android.app.ActivityThread.-wrap12(ActivityThread.java)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1523)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:163)
    at android.app.ActivityThread.main(ActivityThread.java:6238)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:933)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:823)
 Caused by: android.view.InflateException: Binary XML file line #2: Binary XML file line #2: Error inflating class android.support.constraint.ConstraintLayout
 Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class android.support.constraint.ConstraintLayout
 Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.constraint.ConstraintLayout" on path: DexPathList[[zip file "/data/app/com.example.showlatlong-1/base.apk", zip file "/data/app/com.example.showlatlong-1/split_lib_dependencies_apk.apk", zip file "/data/app/com.example.showlatlong-1/split_lib_slice_0_apk.apk", zip file "/data/app/com.example.showlatlong-1/split_lib_slice_1_apk.apk", zip file "/data/app/com.example.showlatlong-1/split_lib_slice_2_apk.apk", zip file "/data/app/com.example.showlatlong-1/split_lib_slice_3_apk.apk", zip file "/data/app/com.example.showlatlong-1/split_lib_slice_4_apk.apk", zip file "/data/app/com.example.showlatlong-1/split_lib_slice_5_apk.apk", zip file "/data/app/com.example.showlatlong-1/split_lib_slice_6_apk.apk", zip file "/data/app/com.example.showlatlong-1/split_lib_slice_7_apk.apk", zip file "/data/app/com.example.showlatlong-1/split_lib_slice_8_apk.apk", zip file "/data/app/com.example.showlatlong-1/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/com.example.showlatlong-1/lib/arm64, /system/lib64, /vendor/lib64]]
    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:380)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
    at android.view.LayoutInflater.createView(LayoutInflater.java:613)
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:812)
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:752)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:499)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:430)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:377)
    at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:555)
    at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:161)
    at com.example.showlatlong.MainActivity.onCreate(MainActivity.java:29)
    at android.app.Activity.performCreate(Activity.java:6857)
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2676)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2784)
    at android.app.ActivityThread.-wrap12(ActivityThread.java)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1523)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:163)
    at android.app.ActivityThread.main(ActivityThread.java:6238)
    at java.lang.reflect.Method.invoke(Native Method)
    at 


 com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit. 
 java:933)
 2019-09-11 12:58:45.344 15400-15400/com.example.showlatlong  
 E/AndroidRuntime:     
 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:823)

在 AndroidManifest.xml 中,您必须将其放在应用程序标记的上方或下方。

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>

因为你没有显示你的代码你一直在做什么,所以我不知道如何解决你的问题。但下面的代码是我在应用程序中用于获取当前用户所在国家/地区的代码。

活动_main.xml

    <?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <TextView
        android:id="@+id/text_view"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Hello World!"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

</android.support.constraint.ConstraintLayout>

MainActivity.java

import android.Manifest;
import android.content.Context;
import android.content.pm.PackageManager;
import android.location.Address;
import android.location.Geocoder;
import android.location.Location;
import android.location.LocationManager;
import android.support.v4.app.ActivityCompat;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.TextView;

import java.util.List;
import java.util.Locale;

public class MainActivity extends AppCompatActivity {

        Location gps_loc;
        Location network_loc;
        Location final_loc;
        double longitude;
        double latitude;
        String userCountry, userAddress;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);


        TextView tv = findViewById(R.id.text_view);

        LocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);


        if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED
                && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED
                && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_NETWORK_STATE) != PackageManager.PERMISSION_GRANTED) {

            return;
        }

        try {

            gps_loc = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
            network_loc = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);

        } catch (Exception e) {
            e.printStackTrace();
        }

        if (gps_loc != null) {
            final_loc = gps_loc;
            latitude = final_loc.getLatitude();
            longitude = final_loc.getLongitude();
        }
        else if (network_loc != null) {
            final_loc = network_loc;
            latitude = final_loc.getLatitude();
            longitude = final_loc.getLongitude();
        }
        else {
            latitude = 0.0;
            longitude = 0.0;
        }


        ActivityCompat.requestPermissions(this, new String[] {Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_NETWORK_STATE}, 1);

        try {

            Geocoder geocoder = new Geocoder(this, Locale.getDefault());
            List<Address> addresses = geocoder.getFromLocation(latitude, longitude, 1);
            if (addresses != null && addresses.size() > 0) {
                userCountry = addresses.get(0).getCountryName();
                userAddress = addresses.get(0).getAddressLine(0);
                tv.setText(userCountry + ", " + userAddress);
            }
            else {
                userCountry = "Unknown";
                tv.setText(userCountry);
            }

        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

你不得不理解这段代码。另一件事是,如果您在模拟器上运行应用程序,它将继续显示“美国”或更具体地说,Googleplex 的位置。只需在真实设备上运行它即可返回您当前的位置。

要返回您当前的位置而不仅仅是国家/地区本身,您可以替换

地址.get(0).getCountryName()

与类似的东西

地址.get(0).getPostalCode()

or

地址.get(0).getAdminArea()

等等。

您也可以将这些值连接为字符串以详细显示您当前的位置。

请看一下this

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

如何使用 GPS 在 Android 中获取我的当前位置? 的相关文章

  • 按下按钮时应用不同的样式

    有没有办法在按下按钮时将样式应用于按钮 如果我有一种风格样式 xml
  • 将现有 VARCHAR 列与 Room 结合使用

    我正在尝试将现有的数据库与 Android Room 一起使用 但是 我的一个表有一个 VARCHAR 列 Room 似乎只支持 TEXT 不支持 VARCHAR 而且 sqlite 不允许修改列类型 那么 有没有办法使用Room中现有的带
  • 通过 WhatsApp 发送消息

    由于我发现了一些较旧的帖子 表明 Whatsapp 不支持此功能 我想知道是否发生了变化 以及是否有办法打开与我通过意图发送的号码进行 Whatsapp 聊天 UPDATE请参阅https faq whatsapp com en andro
  • Bitmap.getPixels() 中的 IllegalArgumentException

    我想将数据从位图复制到int using getPixels 这是我当前的代码 int pixels new int myBitmap getHeight myBitmap getWidth myBitmap getPixels pixel
  • java.lang.IllegalStateException:应用程序 PagerAdapter 更改了适配器的内容,而没有调用 PagerAdapter#notifyDataSetChanged android

    我正在尝试使用静态类将值传递给视图 而不是使用意图 因为我必须传递大量数据 有时我会收到此错误 但无法找出主要原因是什么 Error java lang IllegalStateException The application s Pag
  • 在 android 中建立与 MySQL 的池连接

    我需要从我的 Android 应用程序访问 MySQL 数据库 现在所有的工作都通过 DriverManager getConnection url 等等 但我必须从多个线程访问数据库 所以我必须使用连接池 问题1 是 com mysql
  • 图像作为电子邮件附件

    我想构建一个应用程序 我可以在电子邮件中附加图像 打开图像并将其设置为我的壁纸 我想让它跨平台 所以你能告诉我是否可以使用phonegap 或者我是否必须为iphone和android构建一个本机应用程序 您好 如果您只想通过电子邮件附加图
  • 对于一个单元格,RecyclerView onBindViewHolder 调用次数过多

    我正在将 RecyclerView 与 GridLayoutManager 一起使用 对于网格中的每个项目 我需要调用 REST api 来检索数据 然后 从远程异步获取数据后 我使用 UIL 加载 显示图像 一切似乎都很好 但我发现 on
  • okhttp 获取失败响应

    我已经在我的 android 客户端中实现了 okhttp 来进行网络调用 当我收到失败响应时 我会收到失败代码以及与该代码相关的文本作为消息 但我没有收到服务器发送给我的自定义失败响应 在我实施的代码中的失败响应中 我收到的消息只是 错误
  • OnLongClickListener 不工作

    我有一个ImageView 我需要使用onLongClickListener对于图像视图 当我使用这段代码时 什么也没有发生 Code gallery Gallery findViewById R id gall1 gallery setA
  • Android:无法使用 DbHelper 和 Contract 类将数据插入 SQLite

    public class Main2Activity extends AppCompatActivity private EditText editText1 editText2 editText3 editText4 private Bu
  • Dagger 2 没有生成我的组件类

    我正在使用 Dagger 2 创建我的依赖注入 几个小时前它还在工作 但现在不再生成组件 这是我创建组件的地方 public class App extends Application CacheComponent mCacheCompon
  • 卡片视图 单击卡片移至新活动

    我是 Android 编程新手 正在研究卡片布局 我想知道如何使其可点击 android clickable true android foreground android attr selectableItemBackground 我的卡
  • 在命令行上卸载 Android SDK 的选定部分

    这与 卸载旧的 Android SDK 版本 https stackoverflow com questions 15182377 uninstall old android sdk versions 除非我想在无头 Linux CI 服务
  • 插件“Android Bundle Support”不兼容

    大家好 自从上次更新以来 当我启动 android studio 时 我遇到了一个非常奇怪的错误 我有这个错误 插件错误 插件 Android Bundle Support 不兼容 直到构建 AI 195 SNAPSHOT 我在网上找不到任
  • 问题:为什么React Native Video不能全屏播放视频?

    我正在react native 0 57 7 中为android和ios创建一个应用程序并使用反应本机视频 https github com react native community react native video播放上传到的视频
  • 在 Android 应用程序资源中使用 JSON 文件

    假设我的应用程序的原始资源文件夹中有一个包含 JSON 内容的文件 我如何将其读入应用程序 以便我可以解析 JSON See 开放原始资源 http developer android com reference android conte
  • CamcorderProfile.videoCodec 返回错误值

    根据docs https developer android com reference android media CamcorderProfile html 您可以使用CamcorderProfile获取设备默认视频编解码格式 然后将其
  • 我的应用程序中的后退按钮出现问题[关闭]

    很难说出这里问的是什么 这个问题是含糊的 模糊的 不完整的 过于宽泛的或修辞性的 无法以目前的形式得到合理的回答 如需帮助澄清此问题以便重新打开 访问帮助中心 help reopen questions 我想在手机关闭时清除共享首选项值 你
  • Android 后台倒计时器

    我有一个 Android 应用程序 它管理一个倒计时器 类 CountDownTimer 它显示在应用程序屏幕中 以显示到达 00 00 还剩多少时间 我现在的问题是 当我按主页按钮或启动另一个应用程序时 应用程序 计时器不会在后台运行 所

随机推荐

  • 在 PHP 中动态访问类常量

    我希望能够动态查找常量的值 但使用变量不适用于语法 gives apple banana orange Fatal error Access to undeclared static property Food type 如何动态调用常量
  • 在 AppEngine Python 上使用 Reportlab 生成的 PDF 文档中添加图像文件的正确方法

    我正在尝试使用 App Engine Python 上的 reportlab 生成 PDF 报告 但我不知道如何正确附加图像 图像是静态的 这是我的项目的目录树 这就是我所做的 在 奇帕斯 py 获取图像 im Image static l
  • python脚本的CPU使用率

    是否可以检查简单脚本的CPU使用率 例如 如何获取打印 100 次 hello world 的 CPU 使用率 以百分比表示 目前我正在控制台中获取执行时间 方法是 time p python script py 如果你使用的是 UNIX
  • php 包含文件包含

    我正在一个网站上工作 并被要求包含位于我的 php 脚本上方的文件夹中的文件 问题是那些我被要求包含的 php 文件包含在其中 因此 在调用我的 php 页面时找不到它们引用的文件 处理这种情况的最佳方法是什么 将文件从文件夹 B 包含到文
  • 将客户端证书设置为 Java HTTP 连接中的请求属性?

    我有一个 Java 应用程序 它通过带有 SSL 的套接字连接到另一个 Java 应用程序 因此我的客户端 JVM 已经具有 Djavax net ssl keyStore and Djavax net ssl trustStore属性设置
  • 如何在延迟着色中从光照几何体的内部进行绘制

    我正在尝试使用 OpenGL 和 GLSL 实现延迟着色器 但我在处理光照几何时遇到了问题 这些是我正在采取的步骤 Bind multitarget framebuffer Render color position normal and
  • 访问 Service 中的请求范围 Bean

    我有一颗普通豆 它是 a Scope request 或 b 放置在HttpServletRequest通过过滤器 拦截器 如何在 a 中访问这个 bean Service哪一种是应用程序范围的单例 这样做的原因是 因为我有一个自定义对象R
  • 使用 Heroku 设置 Paperclip Amazon S3

    has attached file image storage gt s3 s3 credentials gt RAILS ROOT config s3 yml path gt style filename 我不知道什么 path gt s
  • 缺少 1 个必需的位置参数:'self'

    这是我的代码 class Email Stuff def init self self emailaddr None self recipaddr None self EmailUser None self EmailPass None d
  • 如何确定文本节点中被点击的字符?

    我可以设置一个事件侦听器来告诉我 HTML 文档中某个位置何时发生鼠标单击 但是 如果单击发生在某些文本上 我需要知道单击发生在文本中的哪个字符上 有没有办法做到这一点 我能想到一些非常令人讨厌的解决方案 例如 对于文档中的每个字符 我可以
  • HttpClient上传大文件并显示发送的字节数

    我找到了这个代码示例 import org apache http params CoreProtocolPNames import org apache http util EntityUtils public class PostFil
  • 从 Excel 将超过 65.535 行导入到 MS Access

    我正在运行以下代码将整个工作表从 Excel 导入到 Access 该工作表有 77k 行 但 Access 仅导入 65 535 行 关于如何修复它有任何疑问吗 Excel 和 Access 都是 2013 版本 Function imp
  • 为什么我们需要将 MDSYS.ST_GEOMETRY 视为 ST_LINESTRING 才能使用 ST_PointN(1)?

    MDSYS ST GEOMETRY 甲骨文18c 以下查询有效 它从 MDSYS ST GEOMETRY 中提取第一个点 Source https www spdba com au using oracles st geometry typ
  • 使用intel内联汇编器编码带有进位的bigint add

    我想做一个快速代码来添加大整数中的 64 位数字 uint64 t ans n uint64 t a n b n assume initialized values for int i 0 i lt n i ans i a i b i 但以
  • 在 webgl 片段着色器中按颜色计算像素

    我有 2d 纹理 S 并且想要返回 3d 纹理 H 这样像素 H r g b 等于纹理 S 中颜色 rgb 的像素数 基本上是纹理 S 中颜色的直方图 我知道遮挡查询 但它仅在 webgl2 中可用 而 IIUC 即使在那里也只能使用布尔结
  • Android SeekBar 拇指自定义

    我想隐藏栏 只想显示拇指 我用 max height 0dip 做到了 但它没有完全起作用 我还想在拇指上设置文本并使用多个图像创建拇指 例如 拇指按钮像图像一样并且具有文本 并且该按钮具有尾部下字 它随着行增量而增加 关于删除背景 我设法
  • 从 python 脚本获取 shell 脚本“读取”值

    外壳脚本 你好 sh bin bash echo Enter your name read name echo Hello name 我想从 python 中调用 Hello sh 并以非交互方式填充变量 name 如何做呢 不知道如何阅读
  • 在 Swift 中的 UITableViewController 之上添加一个 UIView

    我目前使用 UITableViewController PFQueryTableViewController 我想在 TableView 顶部显示一个 UIView 理想情况下 我想在故事板中执行此操作 这样我就可以轻松地向其中添加其他标签
  • nltk下载url授权问题

    我尝试使用 nltk download 更新我的 nltk 数据 但收到 HTTP 错误 401 需要授权 当我追踪有问题的网址时 我在 downloader py 中找到了它 DEFAULT URL http nltk googlecod
  • 如何使用 GPS 在 Android 中获取我的当前位置?

    我想通过 GPS 以地址形式获取我当前的位置 我正在使用android studio 它说我的应用程序停止工作 其中有什么错误呢 有人可以帮我摆脱这个困境吗 我在 Activity main xml 文件中的代码是