小编Nam*_*los的帖子

Google Analytics事件跟踪 - 最大字符串长度

我正在使用Google Analytics跟踪我的Android应用中的事件.我的问题是:事件中的字符串长度是否有限制?我在Googles devguide网站上找不到关于此主题的任何内容.

最好的祝福!

编辑: 我尝试了一个带有2000个字符的字符串 - 它有效.如果你需要更多(我不相信),那就先试试吧.

string events android google-analytics

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

Android - 资源$ NotFoundException

我有一个超过100.000用户的应用程序.但是在某些设备上(~50)我得到一个奇怪的例外.堆栈跟踪说,没有找到可绘制的.
这是堆栈跟踪:

java.lang.RuntimeException: Unable to start activity ComponentInfo{mindmApp.the.big.bang.theory.quiz/mindmApp.the.big.bang.theory.quiz.GameNormalActivity}: android.view.InflateException: Binary XML file line #237: Error inflating class 
...
Caused by: android.view.InflateException: Binary XML file line #237: Error inflating class 
at android.view.LayoutInflater.createView(LayoutInflater.java:606)
at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:653)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:678)
...
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.constructNative(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
at android.view.LayoutInflater.createView(LayoutInflater.java:586)
... 28 more
Caused by: android.content.res.Resources$NotFoundException: File res/drawable/textviewxml_joker.xml from drawable resource ID #0x7f02003d
at android.content.res.Resources.loadDrawable(Resources.java:1956)
at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
at android.view.View.(View.java:2841)
at android.widget.TextView.(TextView.java:580)
at android.widget.TextView.(TextView.java:573)
Run Code Online (Sandbox Code Playgroud)

我不知道为什么没有找到这个drawable(它是一个xml文件).
二进制XML文件行#237是:

<TextView
                    android:id="@+id/textViewSkip"
                    android:layout_width="0px"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="4dp"
                    android:layout_weight="1"
                    android:background="@drawable/textviewxml_joker" …
Run Code Online (Sandbox Code Playgroud)

xml android filenotfoundexception textview drawable

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

libGDX - 透视摄像机和视野

我有问题要理解libGDX中透视摄像机的视野(或者我的计算错误).

我想画一个盒子(例如800px宽,480px高和20px深).该框位于x轴和y轴之间(换句话说:x轴上的宽度和y轴上的高度).现在我想站在x轴(摄像机位置)的方框后面,朝一个方向看,我看到了我屏幕右侧的方框.我做了一些草图:

画框

相机在x轴上,看着盒子

框应该出现在右侧

在最后一个草图上,该框位于视野的右侧.

而且,盒子的高度必须恰好适合屏幕.换句话说:盒子的顶部边缘必须位于我的屏幕顶部,盒子的底部边缘必须位于我的屏幕底部.以下是一些实现此目的的代码和计算:

public class Box implements ApplicationListener {

public PerspectiveCamera camera;
public float SCREEN_WIDTH;   
public float SCREEN_HEIGHT; 

@Override
public void create() {
    SCREEN_WIDTH = Gdx.graphics.getWidth(); // 800px
    SCREEN_HEIGHT = Gdx.graphics.getHeight(); // 480px

    // Create camera (90°) and set position
    camera = new PerspectiveCamera(90f, SCREEN_WIDTH, SCREEN_HEIGHT);
    camera.position.set(SCREEN_WIDTH + SCREEN_HEIGHT/2, SCREEN_HEIGHT/2, 0f);
    camera.lookAt(0f, SCREEN_HEIGHT/2, 0f);
    camera.near = 1;
    camera.far = 2 * SCREEN_WIDTH;
    camera.update();
}

@Override
public void render() {
    Gdx.gl.glClearColor(Color.WHITE.r, Color.WHITE.g, Color.WHITE.b, Color.WHITE.a);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT); 

    // Build the …
Run Code Online (Sandbox Code Playgroud)

camera fieldofview perspective libgdx

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

Tensorflow的初始 - 类的数量

我想知道Tensorflow的Inception实现中的类数.

在他们的训练脚本中,他们加载由图像和标签组成的训练集.接下来,为了计算损失,他们将数量定义为:

# Number of classes in the Dataset label set plus 1.
# Label 0 is reserved for an (unused) background class.
num_classes = dataset.num_classes() + 1
Run Code Online (Sandbox Code Playgroud)

您可以看到他们使用"未使用的背景类".您还可以在创建训练集时看到此方法:build_image_data.py

那么,为什么你需要这样一个未使用的背景类?(特别是因为您从输出层获得了一个额外但无用的预测)

python tensorflow

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

GpsStatus.Listener仅在GPS打开时有效

在我的应用程序中,我有一个GpsStatus.Listener,用于在用户启用或禁用GPS时接收事件.如果在启动应用程序之前启用GPS,一切正常.在这种情况下,每次打开或关闭GPS时,我都会收到GPS_EVENT_STARTEDGPS_EVENT_STOPPED.

问题是如果应用程序启动时GPS已关闭.在这种情况下,如果我打开或关闭GPS,我不会收到任何事件.

有人可以向我解释一下吗?

这是我的代码:

public class GPSTracker implements android.location.GpsStatus.Listener {

    private final Context context;
    private final LocationListener locListener;
    private LocationManager locationManager;
    private boolean isGPSEnabled = false;

    public GPSTracker(Context context, LocationListener locListener) {
            this.context = context;
            this.locListener = locListener; 
            setupGPS();
    }

    private void setupGPS() {
            locationManager = (LocationManager) getContext().getSystemService(Context.LOCATION_SERVICE);                
            locationManager.addGpsStatusListener(this);
            isGPSEnabled = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
            if(!isGPSEnabled) {
                    Toast.makeText(getContext(), "GPS disabled", Toast.LENGTH_SHORT).show();
            } else {        
                    locationManager.removeUpdates(locListener);
                    locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, MIN_TIME, MIN_DISTANCE, locListener);
            }
    }

    @Override
    public …
Run Code Online (Sandbox Code Playgroud)

gps android listener

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