我不需要拨打电话号码,我只需要拨打拨号就可以显示已经显示的电话号码.我Intent
应该用什么来实现这个目标?
Android 6和7有一些功耗优化(打盹模式),在不使用设备时限制应用程序网络.
用户可以在电池设置中禁用任何应用的优化模式:
是否可以检查是否为我的应用启用了优化?我需要让用户禁用优化以获得更好的应用功能,但我不知道如何以编程方式检查它.
我对三星设备上的服务的后台工作有问题。
Fatal Exception: android.app.RemoteServiceException: Context.startForegroundService() did not then call Service.startForeground()
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1881)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6938)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)
Run Code Online (Sandbox Code Playgroud)
当然,启动服务后,我会调用Service.startForeground(),而在其他设备上就没有问题,仅三星设备就没有问题。
有人知道这个问题的原因和解决方法吗?
我在Zopim SDK https://chat.zendesk.com/hc/en-us/community/posts/360004395368-Crash-on-Android-8-in-Android-SDK-1-4-2中发现了类似的问题
我需要从哪个设备断开网络.
现在我使用:
NetworkInfo ni =intent.getParcelableExtra(ConnectivityManager.EXTRA_NETWORK_INFO);
Run Code Online (Sandbox Code Playgroud)
并检查:
ni.isConnected()
Run Code Online (Sandbox Code Playgroud)
如果返回false ni - 是设备断开连接的网络.
但ConnectivityManager.EXTRA_NETWORK_INFO
被弃用的API 14.谷歌表示,使用getActiveNetworkInfo()来获取网络信息.但是getActiveNetworkInfo()总是返回设备现在连接的网络(isConnected()
必须返回true)!
如何在不使用ConnectivityManager.EXTRA_NETWORK_INFO的情况下获取设备断开连接的网络的网络信息?
Sertorio Noronha,当我使用getActiveNetworkInfo()时,我只获得了我现在连接的网络!但我需要从我断开连接的网络.
ConnectivityManager cm = (ConnectivityManager)
context.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo n1 = cm.getActiveNetworkInfo();
Log.d("tets", String.format("%s: %s", n1.getTypeName(), n1.isConnected()));
Run Code Online (Sandbox Code Playgroud)
当我从WI-FI断开并连接到日志中的3G时:
mobile: true
mobile: true
Run Code Online (Sandbox Code Playgroud)
当我从3G断开并连接到日志中的WI-FI时:
WIFI: true
WIFI: true
WIFI: true
Run Code Online (Sandbox Code Playgroud)
getActiveNetworkInfo仅返回连接到now的网络,但不返回断开连接的网络.
如果我在日志中使用弃用的intent.getParcelableExtra(ConnectivityManager.EXTRA_NETWORK_INFO),我会看到:
当我断开WI-FI并连接到3G时:
WIFI: false
mobile: true
Run Code Online (Sandbox Code Playgroud)
当我断开与3G的连接并连接到WI-FI时:
mobile: false
WIFI: true
Run Code Online (Sandbox Code Playgroud)
但我不想使用弃用的api.如何使用现代api来获取我断开连接的网络?
我需要从网络和GPS提供商处接收位置更改.
如果GPS提供商不可用或没有位置(卫星可见性差)我会从网络提供商处获得GPS提供商的位置.
是否有可能根据我的需要选择使用标准?
我有一个向RelativeLayout添加新状态但是onCreateDrawableState方法永远不会调用.
我的班级是:
public class UnreadableRelativeLayout extends RelativeLayout
{
private static final int[] STATE_UNREADED = {R.attr.state_unreaded};
private boolean isUnreaded = false;
public UnreadableRelativeLayout(Context context)
{
super(context);
}
public UnreadableRelativeLayout(Context context, AttributeSet attrs)
{
super(context, attrs);
}
public UnreadableRelativeLayout(Context context, AttributeSet attrs, int defStyle)
{
super(context, attrs, defStyle);
}
public void setUnreaded(boolean isUnreaded)
{
if (this.isUnreaded != isUnreaded)
{
this.isUnreaded = isUnreaded;
refreshDrawableState();
}
}
@Override
protected int[] onCreateDrawableState(int extraSpace)
{
final int[] drawableState = super.onCreateDrawableState(extraSpace + 1);
if (isUnreaded) mergeDrawableStates(drawableState, STATE_UNREADED); …
Run Code Online (Sandbox Code Playgroud) 只能对Android中的主线程使用方法分析?
现在要在所有线程中分析方法,我按下DDMS中的"启动方法分析".我可以只在主线程中分析方法吗?
我需要始终显示ListView标头,即使ListView没有项目.
有可能吗?或者更好地在ListView中添加标题作为第一项?
我尝试CheckBox
使用RelativeLayout
with TextView
和FrameLayout
(在背景上使用选择器)编写我自己的内容.
我setDuplicateParentStateEnabled(true)
为FrameLayout
它取从父辨认的状态,但为什么做RelativeLayout
辨认的,我不知道.
public class MyCheckbox extends RelativeLayout implements OnClickListener, Checkable
{
private static final int ID_CHECKBOX = -1234411;
private static final int ID_TEXTVIEW = -1234412;
private static final int ID_PARENT = -1234413;
private TextView textView;
private FrameLayout checkBox;
private boolean isChecked;
public MyCheckbox(Context context)
{
this(context, null);
}
public MyCheckbox(Context context, AttributeSet attrs)
{
super(context, attrs);
LayoutParams lp;
setId(ID_PARENT);
setOnClickListener(this);
// checkBox
checkBox = new FrameLayout(context); …
Run Code Online (Sandbox Code Playgroud) 我需要在我的应用中接收来自不同发件人的推送通知.它会起作用吗?
android ×10
background ×1
connectivity ×1
criteria ×1
drawable ×1
header ×1
listview ×1
location ×1
networking ×1
phone-number ×1
powermanager ×1
profiling ×1
push ×1
service ×1
state ×1