让我们试着解释一下我的问题:我得到了一个应用程序和一个服务.应用程序以活动A启动.服务发送一个广播,让应用程序启动活动B现在用户启动活动C.
现在该服务想再次启动活动B. 但是我怎么让他知道活动仍然在堆栈上,或者是否有一个意图标志?
我如何避免它会启动活动B,因为它已经在堆栈中?
我的每个项目ListView包含一个ImageView和一个TextView,这将填充远程信息.
我有一个URL ImageView,因此我开始AsyncTask下载图像,并将setImageBitmap使用下载的位图调用.
这很顺利,但是当创建ListView时,getView()经常会调用它.它调用getView前10行的7倍(只有7行可见).(所以:0,1等,10,0,1等).
然后我可以顺利滚动到第10项.但在那之后,对于每个新行,listview再次调用getView前10个项目的7倍.(这会导致滞后..)
但是当我setImageBitmap从中删除时AsyncTask,这一切都不会发生!
可能是什么问题呢?可能是某些布局是大的,这将导致另一连串的getViews?
这里有一些代码:
<ListView
android:id="@+id/mylist"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_alignParentBottom="true"
android:layout_below="@+id/mydivider"
android:divider="@+color/mycolor"
android:dividerHeight="2dp"
android:fadingEdge="none"
android:fastScrollEnabled="true"
android:listSelector="@android:color/transparent"
android:scrollbars="horizontal"
android:scrollingCache="false"
android:smoothScrollbar="false" />
Run Code Online (Sandbox Code Playgroud)
AsyncTask:
public static class MyTask extends AsyncTask<String, Integer, Bitmap> {
private LruCache<String, Bitmap> mMap;
private String mUri;
private int mPosition;
private ViewHolder mHolder;
public MyTask (ViewHolder holder, int position, LruCache<String, Bitmap> map) {
mMap = map; …Run Code Online (Sandbox Code Playgroud) 在Chrome custom tabs似乎并不受deeplinking启动其他应用程序.
例如,Chrome使用此URL启动时的PayPal付款.它将询问用户是否必须使用PayPal应用程序或Chrome打开URL.
但事实并非如此Chrome custom tabs.
如果我使用自定义方案(myapp://deeplinkurl/)它可以正常工作.
如何允许应用程序覆盖http方案?
我创建了自己的内容提供者,我将多个插入的数据同时放入大量数据中.
该应用程序将从外部源接收数据,此时我收到大约30个项目(因此插入30次).
现在我注意到这需要花费很多宝贵的时间(大约3秒,每次插入100毫秒).
如何提高contentprovider的速度?我已经尝试将它们全部拼接在一起,但它们最多需要5秒钟.
提前致谢.
我的后台服务正在尽快向本地服务器发送消息.每条消息通常需要大约30毫秒.但是当手机处于睡眠模式时,它需要大约400ms-1000ms(使用'正确'的Wifi政策关闭屏幕)
在我的服务中,我使用以下代码来获取Wifi锁和WakeLock.
PowerManager lPowerManager = (PowerManager) getSystemService(Context.POWER_SERVICE);
mWakeLock = lPowerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "WakeLockTag");
WifiManager lWifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR1) {
mWifiLock = lWifiManager.createWifiLock(WifiManager.WIFI_MODE_FULL_HIGH_PERF, "LockTag");
} else {
mWifiLock = lWifiManager.createWifiLock(WifiManager.WIFI_MODE_FULL, "LockTag");
}
mWifiLock.acquire();
mWakeLock.acquire();
Run Code Online (Sandbox Code Playgroud)
是否有可能获得与屏幕开启时相同的性能?
当我调用dismissViewControllerAnimated:completion:dismiss UIViewController时,当相应的视图正在动画到屏幕上时(使用presentViewController:animated:completion:),从不执行完成块.
该UIViewController甚至不dissappear.这就像dismissViewControllerAnimated:completion:被忽略了.
以下代码是一个简化的代码示例,因为原始代码要大得多.我在下面给出的代码模拟了一个用例,其中网络通信错误可能触发视图弹出,而另一个视图也同时弹出.
代码示例:
NSLog(@"Presenting view");
[self presentViewController:changeLocationViewController animated:YES completion:^{
NSLog(@"View done presenting");
}];
NSLog(@"Dismissing view");
[self dismissViewControllerAnimated:NO completion:^{
NSLog(@"View done dismissing");
}];
Run Code Online (Sandbox Code Playgroud)
日志输出是:
2013-08-28 16:14:12.162 [1708:c07]提出观点
2013-08-28 16:14:12.178 [1708:c07]解雇观点
2013-08-28 16:14:12.583 [1708:c07]查看做完了
有谁知道UIViewController在这些情况下如何解雇?
提前致谢.
嗨,我正在创建一个Android应用程序作为XMPP客户端到ejabbered服务器.
但我真的很困惑,因为我看到我可以发送消息作为apacket或消息,我也可以使用PacketListener和收到消息MessageListener.
是什么PacketListener和MessageListener接收消息的好方法之间的区别是什么?使用数据包监听器或消息监听器?
我正在尝试创建一个使用所选主题定义的属性的选择器。
属性文件
<declare-styleable name="ThemeColors">
<attr name="buttonTextColor" format="color" />
</declare-styleable>
Run Code Online (Sandbox Code Playgroud)
选择器.xml
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:state_pressed="true" android:color="@android:color/black" />
<item android:color="?attr/buttonTextColor"/>
</selector>
Run Code Online (Sandbox Code Playgroud)
主题:
<style name="Theme.Test" parent="@style/Theme.AppCompat">
<item name="buttonTextColor">@android:color/white</item>
</style>
Run Code Online (Sandbox Code Playgroud)
部分布局文件:
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/test"
android:textColor="@drawable/selector" />
Run Code Online (Sandbox Code Playgroud)
显现
<application
...
android:theme="@style/Theme.Test" >
Run Code Online (Sandbox Code Playgroud)
布局文件由该setContentView方法膨胀。
现在的问题是 textcolorRED处于未按下状态(按下时为黑色)。似乎找不到buttonTextColor并使用默认值RED(?)
已经尝试将主题设置为应用程序上下文,但没有运气..
提前致谢。
在我的应用程序中,我正在使用一些带有LevelListDrawables的Imageview,以便能够动态地进行更改.
但现在我想知道我是否可以读取ImageView的哪个级别,我使用setImageLevel()设置级别,但是没有反对悬挂方法来获取imagelevel.
所以我的问题是:有没有办法获得imageview的当前图像级别?
我尝试在选择器中使用主题更改文本颜色但我已经使用相同的颜色:#fff(我的colors.xml中没有这个颜色!)
这是我的selector.xml(在drawable /中):
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_selected="true" android:color="@android:color/white" />
<item android:state_focused="true" android:color="@android:color/white" />
<item android:state_pressed="true" android:color="@android:color/white" />
<item android:color="?attr/tabsTextColor" />
</selector>
Run Code Online (Sandbox Code Playgroud)
我的attrs.xml文件:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<attr name="tabsTextColor" format="color" />
</resources>
Run Code Online (Sandbox Code Playgroud)
Colors.xml文件:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- ... -->
<color name="tabs_text_color">#ff0</color>
</resources>
Run Code Online (Sandbox Code Playgroud)
我的theme.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.Custom" parent="@style/Theme.GreenDroid.NoTitleBar">
<item name="tabsTextColor">@color/tabs_text_color</item>
</style>
</resources>
Run Code Online (Sandbox Code Playgroud)
我不明白,因为文字颜色是红色的(用photoshop获得#f00)但不是#ff00!
哪里出错了?谢谢
编辑:我替换我的布局
android:textColor="@drawable/selector.xml"
Run Code Online (Sandbox Code Playgroud)
通过
android:textColor="?attr/tabsTextColor"
Run Code Online (Sandbox Code Playgroud)
而且颜色很好!我不能使用主题attr选择器?
我得到了一个绑定的活动和服务.
当在ServiceConnection中调用onServiceConnected时,我会做下一件事:
mInterfaceObject = IInterface1.Stub.asInterface(arg1);
mInterfaceObject.register(mController);
Run Code Online (Sandbox Code Playgroud)
mController的位置是:
private final IInterface2.Stub mController = new IInterface2.Stub() {
Run Code Online (Sandbox Code Playgroud)
IInterface1和IInterface2都是AIDL文件.
现在问题.在服务中执行寄存器.该参数将为null.
我究竟做错了什么?