小编Sol*_*ety的帖子

关闭应用程序后,保持位置服务活动

我有一项服务,当用户更改他/她的位置时会发送通知.此服务工作正常,但是当用户关闭应用程序时服务关闭也会出现问题.

即使应用程序已关闭,我如何才能使服务仍然存在?

我的服务是:

public class LocationService extends Service implements LocationListener {
    public final static int MINUTE = 1000 * 60;


    boolean isGPSEnabled = false;
    boolean isNetworkEnabled = false;
    boolean canGetLocation = false;

    Location location; // location
    double latitude = 0; // latitude
    double longitude = 0; // longitude
    String provider;

    // The minimum distance to change Updates in meters
    private static final long MIN_DISTANCE_CHANGE_FOR_UPDATES = 10;

    // The minimum time between updates in milliseconds
    private static final long MIN_TIME_BW_UPDATES = …
Run Code Online (Sandbox Code Playgroud)

android location android-service

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

URL方案在Android浏览器中不起作用

点击链接时我需要打开我的应用程序.为此,我读到我必须使用URL方案.该链接必须具有myapp://参数形式.

我阅读了关于这个主题的每篇文章,但是当我发送一封带有"myapp:// addUser /?id = 22"的电子邮件并且我从chrome(在我的手机上)打开时,它无法点击.

我的清单:

 <activity
            android:name="com.example.SplashActivity"
            android:label="@string/app_name"
            android:screenOrientation="portrait" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                    <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
            <intent-filter>
             <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />
                <data android:scheme="myapp" android:host="com.example"/>
            </intent-filter>

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

我的课:

公共类SplashActivity扩展FragmentActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
   setContentView(R.layout.activity_splash);
    Intent intent = getIntent();

    if (Intent.ACTION_VIEW.equals(intent.getAction())) {
        Uri uri = intent.getData();
        String id = uri.getQueryParameter("id"); 
    }

}
Run Code Online (Sandbox Code Playgroud)

要测试代码的邮件内容:

myapp://addUser/?id=22
Run Code Online (Sandbox Code Playgroud)

参考链接:

在Android浏览器中建立一个链接启动我的应用程序?

如何通过在Android OS中的浏览器中调用URL来注册一些URL命名空间(myapp://app.start/)来访问您的程序?

https://legacy.madewithmarmalade.com/devnet/forum/custom-url-scheme-primarily-android-3

UPDATE

我认为问题是邮件正文,但我不知道如何测试它.

android url-scheme

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

使用Sentry监控错误 - Android

我需要为我的Android应用程序实现Sentry,我试图找到一个关于我如何实现它的例子,但我找不到它.我在http://sentry.readthedocs.org/en/latest/developer/client/index.html#server_name中看到了Sentry文档

但我有一些问题.如果我的应用程序崩溃,将捕获异常?我应该将此代码行放入我的try/catch中吗?var $ resultId = myClient-> captureException($ myException); (在android代码中)

如果有人在android中有样本我将不胜感激.

谢谢!

android sentry

5
推荐指数
2
解决办法
6185
查看次数

图库:选定项目中的效果

我需要一起滚动项目,所选项目应该向下扩展一部分.

在此输入图像描述

我目前正在使用一个Gallery(我尝试使用viewflow和viewpager,但这些项目之间有很大的空间),但我需要知道如何才能实现此效果.

我有2个想法,但我不知道如何实现它.

1)可扩展部分是LinearLayout,其中visibility = gone,当选择该项时,此布局应该是可见的.(图库没有"onItemSelectedListener")

2)将每个元素视为一个片段(一旦我使用一个使用它的Viewpager, https://github.com/mrleolink/SimpleInfiniteCarousel)

它不一定是画廊,任何想法都是受欢迎的

我正在开展一项活动.

android android-gallery android-viewpager

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

Android - TFLite OD - 无法从具有 4320000 字节的 Java 缓冲区复制到具有 307200 字节的 TensorFlowLite 张量 (normalized_input_image_tensor)

我正在尝试运行我自己的自定义模型来进行对象检测。我从 Google Cloud - Vision ( https://console.cloud.google.com/vision/ )创建了我的数据集(我对图像进行了装箱和标记),它看起来像这样:

在此处输入图片说明

训练模型后,我从这里下载了 TFLite 文件(labelmap.txt、model.tflite 和一个 json 文件):

在此处输入图片说明

然后,我将它们添加到 Android 对象检测示例 ( https://github.com/tensorflow/examples/tree/master/lite/examples/object_detection/android )。

在此处输入图片说明

但是当我运行该项目时,它崩溃了:

2020-07-12 18:03:05.160 14845-14883/? E/AndroidRuntime: FATAL EXCEPTION: inference
    Process: org.tensorflow.lite.examples.detection, PID: 14845
    java.lang.IllegalArgumentException: Cannot copy to a TensorFlowLite tensor (normalized_input_image_tensor) with 307200 bytes from a Java Buffer with 4320000 bytes.
        at org.tensorflow.lite.Tensor.throwIfSrcShapeIsIncompatible(Tensor.java:423)
        at org.tensorflow.lite.Tensor.setTo(Tensor.java:189)
        at org.tensorflow.lite.NativeInterpreterWrapper.run(NativeInterpreterWrapper.java:154)
        at org.tensorflow.lite.Interpreter.runForMultipleInputsOutputs(Interpreter.java:343)
        at org.tensorflow.lite.examples.detection.tflite.TFLiteObjectDetectionAPIModel.recognizeImage(TFLiteObjectDetectionAPIModel.java:197)
        at org.tensorflow.lite.examples.detection.DetectorActivity$2.run(DetectorActivity.java:182)
        at android.os.Handler.handleCallback(Handler.java:883)
        at android.os.Handler.dispatchMessage(Handler.java:100)
        at android.os.Looper.loop(Looper.java:214)
        at android.os.HandlerThread.run(HandlerThread.java:67)
Run Code Online (Sandbox Code Playgroud)

我尝试将参数TF_OD_API_IS_QUANTIZED更改为 false 并将labelOffset 更改为 0,并且我还将这一行从 TFLiteObjectDetectionAPIModel.java …

android google-cloud-platform tensorflow tensorflow-lite

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