小编Mer*_*yth的帖子

如何检查是否启用了位置服务?

我正在Android OS上开发一款应用.我不知道如何检查是否启用了位置服务.

我需要一个方法,如果它们被启用则返回"true",否则返回"false"(所以在最后一种情况下我可以显示一个对话框来启用它们).

service android location

208
推荐指数
10
解决办法
22万
查看次数

如何在另一个字符串中搜索字符串?

可能重复:
如何查看Java 1.4中另一个字符串中是否存在子字符串

我如何在另一个字符串中搜索字符串?

这是我所说的一个例子:

String word = "cat";
String text = "The cat is on the table";
Boolean found;

found = findInString(word, text); //this method is what I want to know
Run Code Online (Sandbox Code Playgroud)

如果字符串"word"在字符串"text"中,则方法"findInString(String,String)"返回true,否则返回false.

java string

28
推荐指数
2
解决办法
17万
查看次数

Java:如何用一些字符拆分字符串?

我试图在网上搜索解决这个问题,但我没有找到任何东西.

我写了以下抽象代码来解释我在问什么:

String text = "how are you?";

String[] textArray= text.splitByNumber(4); //this method is what I'm asking
textArray[0]; //it contains "how "
textArray[1]; //it contains "are "
textArray[2]; //it contains "you?"
Run Code Online (Sandbox Code Playgroud)

splitByNumber方法每4个字符拆分字符串"text".我怎么能创建这个方法?

非常感谢

java string split numbers character

28
推荐指数
3
解决办法
10万
查看次数

如何在Android 4.2上以编程方式启用和禁用Flight模式?

有没有办法在Android 4.2上禁用或启用飞行模式?

我使用的代码仅适用于以前的Android版本:

android.provider.Settings.System.putInt(
    c.getContentResolver(),   
    android.provider.Settings.System.AIRPLANE_MODE_ON, enable ? 0 : 1
);
Run Code Online (Sandbox Code Playgroud)

android airplane

25
推荐指数
3
解决办法
6万
查看次数

Android:如何将通知放在通知区域之上?

我正在尝试将通知放在通知区域之上.

解决方案是将参数"when"设置为我的通知对象,其未来时间如下:

notification.when = System.currentTimeMills()*2; 
Run Code Online (Sandbox Code Playgroud)

我正在使用的代码:

        long timeNotification = System.currentTimeMillis()*2;
        Notification notification = new Notification(statusIcon,c.getResources().getString(R.string.app_name),timeNotification);
        notification.flags = Notification.FLAG_ONGOING_EVENT | Notification.FLAG_NO_CLEAR;
        notification.when = timeNotification;
        notification.priority = Notification.PRIORITY_MAX;
Run Code Online (Sandbox Code Playgroud)

但是有些应用程序(比如Facebook)可以用他们当前的时间对我进行简单的通知.

如果我刷新我的通知,它仍然在这些通知之下.

我需要设置哪些参数才能将我Notification置于通知区域的顶部?

notifications android notification-bar android-notification-bar

21
推荐指数
2
解决办法
3万
查看次数

如何在状态栏中创建没有图标的通知或只是隐藏它?

我想知道如何创建一个不在状态栏中显示图标的通知.

有一种方法可以隐藏它吗?

icons android android-notifications android-statusbar

12
推荐指数
2
解决办法
7422
查看次数

Eclipse:"Run as"不显示列表元素(例如"Run as android application")

今天早上我更新了我的Ubuntu版本,现在我无法从eclipse运行我的应用程序.

问题是当我点击"运行方式"时出现的列表是空的,我无法运行任何东西.

我怎么能解决这个问题?

我能看到的唯一错误告诉我:

An internal error occurred during: "Compute launch button tooltip".
org/eclipse/cdt/core/model/CoreModel
Run Code Online (Sandbox Code Playgroud)

eclipse runas

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

Android有时我得到android.app.RemoteServiceException:从包发布不良通知.为什么?

我的通知存在严重问题.

有时当我的应用发布相同的自定义通知时,我收到此错误:

android.app.RemoteServiceException: Bad notification posted from package  com.packagename: Couldn't expand RemoteViews for: ClassName(package=com.packagename id=0     tag=null notification=Notification(vibrate=null,sound=null,defaults=0x0,flags=0x22))
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1093)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3906)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:840)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:598)
at dalvik.system.NativeStart.main(Native Method)
Run Code Online (Sandbox Code Playgroud)

我该怎么办?

该通知仅包含LinearLayout,TextViews和ImageViews,并且大部分时间都可以完美运行.

有一种方法可以用try/catch包围这个错误所以这样android不能阻止我的应用程序?

非常感谢...

notifications android exception

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

Android:如何在Android 4.2上崩溃状态栏?

有没有办法折叠Android 4.2上的通知栏?

我使用的代码仅适用于以前的Android版本:

try{
            Object service  = c.getSystemService("statusbar");
            Class<?> statusbarManager = Class.forName("android.app.StatusBarManager");
            Method collapse = statusbarManager.getMethod("collapse");
            collapse.setAccessible(true);
            collapse.invoke(service);
        }catch(Exception ex){}
Run Code Online (Sandbox Code Playgroud)

请帮我...

notifications android collapse android-notification-bar

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

Android如何设置RemoteView的权限?

我需要知道允许我设置RemoteView权重的代码.

我尝试使用此代码,但这不起作用:

RemoteViews remoteViews = new RemoteViews(c.getPackageName(), R.layout.notification);
remoteViews.setInt(R.id.ll_notification, "setWeight", 12);
Run Code Online (Sandbox Code Playgroud)

有办法做到这一点?非常感谢....

android remoteview android-layout-weight

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