【问题标题】:why package manager is always is null?为什么包管理器总是为空?
【发布时间】:2015-11-13 08:46:28
【问题描述】:

我尝试在我的 android 应用程序中显示用户位置,但它不起作用!包管理器始终为空。

private void openPrefredLocationInMap (){
    String location =
            PreferenceManager.getDefaultSharedPreferences(this)
                    .getString(getString(R.string.pref_location_key)
                            , getString(R.string.pref_defult));

    Uri geoLocation = Uri.parse("geo:0,0?").buildUpon()
            .appendQueryParameter("q", location).build();

    Intent intent= new Intent(Intent.ACTION_VIEW,geoLocation);
    if (intent.resolveActivity(getPackageManager()) != null)
        startActivity(intent);
     else
        Log.d("package","couldnt call"+location);
}

【问题讨论】:

    标签: java android


    【解决方案1】:

    您的设备没有可以处理此类意图的应用程序。安装一个可以处理该意图或自己制作的应用程序。更具体地说,您可能没有能够显示地理位置意图的地图应用程序。

    例如尝试安装谷歌地图。

    【讨论】:

      猜你喜欢
      • 2017-06-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-03-07
      • 2016-12-07
      • 1970-01-01
      • 1970-01-01
      • 2022-09-27
      相关资源
      最近更新 更多