2015-11-13 28 views
1

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

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

回答

4

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

尝试安装Google地图。