小编Gui*_*res的帖子

NETWORK_PROVIDER的LocationListener已启用,但永远不会调用onLocationChanged

我正在开发一个应用程序,在服务中的6分钟和6分钟内整天获得手机的位置,它工作正常,但有时OnLocationChanged网络提供者监听器的方法停止被调用,我不知道为什么.

它由于某种原因停止被调用,但是当我手动启用或禁用提供程序onProviderEnabled并且onProviderDisabled被调用时,提供程序已启用且Lister正在工作.

它恰好发生NETWORK_PROVIDER,GPS_PROVIDER效果很好.

监听器:

LocationListener locationListenerGPS = new LocationListener() {
        // @Override
        public void onStatusChanged(String provider, int status, Bundle extras) {
            // TODO locationListenerGPS onStatusChanged
            Log.d(TAG, "Provedor trocado");
        }

        // @Override
        public void onProviderEnabled(String provider) {
            Log.w(TAG, "PROVEDOR " + provider + " HABILITADO!");
        }

        // @Override
        public void onProviderDisabled(String provider) {
            Log.w(TAG, "PROVEDOR " + provider + " DESABILITADO!");
        }

        // @Override
        public void onLocationChanged(Location location) {

            longitudeGPS = …
Run Code Online (Sandbox Code Playgroud)

gps android geolocation locationmanager locationlistener

42
推荐指数
2
解决办法
4万
查看次数

如何把50%的宽度

我有一个水平方向的LinearLayout和2个ImageView,我想让ImagesView在宽度上填充50%的屏幕,适用于不同大小的每个手机或平板电脑.

像这样的东西:

 +-------------+   
 |_____________|     
 |      |      |  
 | 50%  | 50%  |  
 |      |      |   
 |-------------|
 |             |
 +-------------+
Run Code Online (Sandbox Code Playgroud)

迄今为止最好的:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:gravity="center"
    android:orientation="horizontal" >


        <ImageView
            android:id="@+id/logo_c"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/logo_animado" />

        <ImageView
            android:id="@+id/logo_t"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:src="@drawable/logo_animado2" />


</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

layout android imageview android-layout

7
推荐指数
1
解决办法
8035
查看次数

Textview调整文本当屏幕比其他屏幕大时

我想调整textview的大小,因为有些文字在平板电脑中很小但在手机中是正常的.

码:

public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
            setContentView(R.layout.loading);
         TextView txt = (TextView) findViewById(R.id.text);
         txt.setTextAppearance(this, android.R.attr.textAppearanceLarge);
Run Code Online (Sandbox Code Playgroud)

java android textview android-layout

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