小编KIS*_*_ZE的帖子

错误在空对象引用上调用虚方法'double android.location.Location.getLatitude()'

我所要做的就是让用户获得他喜欢的类型的列表.例如,如果输入是医院,我的应用程序将使用搜索字符串"Hospital"打开谷歌地图.但正如使用像geo:0,0?q=hospitaluri 这样的地理编码的文档中的建议显示了坐标0纬度和经度0附近的所有医院.因此,当我尝试使用以下代码首先获取用户坐标时.

放置Decoder.java

package com.kkze.Mappy;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.location.Criteria;
import android.location.Location;
import android.location.LocationManager;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.provider.Settings;
import android.text.TextUtils;
import android.util.Log;
import android.widget.Toast;

public class PlacesDecoder extends Activity {
Intent intentThatCalled;
public double latitude;
public double longitude;
public LocationManager locationManager;
public Criteria criteria;
public String bestProvider;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    intentThatCalled = getIntent();
    String voice2text = intentThatCalled.getStringExtra("v2txt");
    getLocation(voice2text);
}
public static boolean isLocationEnabled(Context …
Run Code Online (Sandbox Code Playgroud)

java android location google-maps nullpointerexception

11
推荐指数
1
解决办法
5万
查看次数

TextToSpeech setLanguage无法正常工作?

我正在设置我的TextToSpeech使用特定语言(英语 - 英国),使用语言环境"en_GB".但它总是使用我的设备默认语言.有没有办法以编程方式设置它?我已下载该语言所需的文件,当我将TTS的默认语言更改为"英语 - 英国"时,它可以正常工作,但是当默认值不同时,编程方法不起作用.我已尽力浏览网页,但无法解决此问题.

    String ttsEngine = "com.google.android.tts";
    txt2Speech = new TextToSpeech(this, this, ttsEngine);
    //Locale ttsLocale = new Locale("eng", "GBR");
    txt2Speech.setLanguage(new Locale("en_GB"));
Run Code Online (Sandbox Code Playgroud)

尝试了几种方法,但都没有.我不能以编程方式设置我的TTS语言吗?

谢谢

编辑:回应'A Honey Bustard'

其他代码:

public class MainActivity extends AppCompatActivity implements TextToSpeech.OnInitListener
Run Code Online (Sandbox Code Playgroud)

我的 onInit()

public void onInit(int status) {
    // TODO Auto-generated method stub

}
Run Code Online (Sandbox Code Playgroud)

我的初始化时,我也会打电话给.setLanguage()我.那是对的吗?我也只打电话一次.每次都不需要打电话吗?我也正在测试GS7onCreate()TextToSpeech

java android locale text-to-speech google-text-to-speech

5
推荐指数
1
解决办法
1277
查看次数

获取android中所有已安装应用程序的名称,图标和包名称

我希望能够获得手机中安装的所有应用程序的字符串包名称和图标.我做了什么:浏览并找到了这个解决方案

final Intent mainIntent = new Intent(Intent.ACTION_MAIN, null); 
            mainIntent.addCategory(Intent.CATEGORY_LAUNCHER); 
            final List pkgAppsList = this.getPackageManager().queryIntentActivities(mainIntent, 0);
            for(int counter = 0; counter<=pkgAppsList.size()-1;counter++)
            {
                    Log.e("TAG", pkgAppsList.get(counter).toString());
  } 
Run Code Online (Sandbox Code Playgroud)

问题是它显示包和类名作为混合,我无法获得图标.我想要的是向用户显示带有图标的手机上安装的所有应用程序的列表.而且我还需要能够获得包名称List.OnItemClickListener.我假设使用一组具有相同定位的应用程序名称和包名称,我可以做到这一点.但是,我如何获得包名称的应用程序图标和名称.最好作为Array或ArrayList,我可以将其转换为listView对象.如果有任何替代方法,请告诉我.我还是Android的初学者.

请帮忙.

java android listview package-managers android-intent

4
推荐指数
1
解决办法
8084
查看次数