我平时在使用短消息strings.xml为TextViewS和其他部件.我在哪里可以存储长文本?如果我需要存储大型用户指南并进行本地化,该怎么办?
<string name="instruction_will_be_soon">Lorem Ipsum ist ein einfacher Demo-Text für die Print- und Schriftindustrie. Lorem Ipsum ist in der Industrie bereits der Standard Demo-Text seit 1500, als ein unbekannter Schriftsteller eine Hand voll Wörter nahm und diese durcheinander warf um ein Musterbuch zu erstellen. Es hat nicht nur 5 Jahrhunderte überlebt, sondern auch in Spruch in die elektronische Schriftbearbeitung geschafft (bemerke, nahezu unverändert). Bekannt wurde es 1960, mit dem erscheinen von "Letraset", welches Passagen von Lorem Ipsum …Run Code Online (Sandbox Code Playgroud) 我是新来RxJava和RxAndroid,并试图了解之间的差异Observable.just和Single.看起来每个都被设计为为其观察者发射一个项目.
这是我的简单Android活动的代码,带有两个按钮.第一个按钮创建一个Observable,第二个按钮创建一个Single:
findViewById(R.id.just).setOnClickListener(view -> Observable.just("item").subscribe(
new Observer<String>() {
@Override
public void onSubscribe(Disposable d) {
Log.d(LOG_TAG, "just onSubscribe");
}
@Override
public void onNext(String s) {
Log.d(LOG_TAG, "just s=" + s);
}
@Override
public void onError(Throwable e) {
Log.e(LOG_TAG, "just e=" + e);
}
@Override
public void onComplete() {
Log.d(LOG_TAG, "just onComplete");
}
}));
findViewById(R.id.single).setOnClickListener(
view -> Single.create((SingleOnSubscribe<String>) e -> {
})
.subscribe(new SingleObserver<String>() {
@Override
public void onSubscribe(Disposable d) {
Log.d(LOG_TAG, "single onSubscribe"); …Run Code Online (Sandbox Code Playgroud) 我需要在Android应用中测试一项活动.文件ActivityInstrumentationTestCase2说:
此类提供单个活动的功能测试.
文档ActivityTestRule说:
此规则提供单个活动的功能测试.
几乎一样的话.除了我编码的两个样本,做同样的事情.我应该更喜欢ActivityTestRule,ActivityInstrumentationTestCase2反之亦然?
我看到的是,扩展ActivityInstrumentationTestCase2看起来像JUnit3风格的测试(它的祖先是junit.framework.TestCase,测试方法应该从单词开始test).
使用ActivityTestRule
package sample.com.sample_project_2;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
import android.test.suitebuilder.annotation.LargeTest;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import static android.support.test.espresso.Espresso.onView;
import static android.support.test.espresso.action.ViewActions.typeText;
import static android.support.test.espresso.matcher.ViewMatchers.withId;
@RunWith(AndroidJUnit4.class)
@LargeTest
public class ApplicationTest {
@Rule
public ActivityTestRule<SecAct> mActivityRule = new ActivityTestRule(SecAct.class);
@Test
public void foo() {
onView(withId(R.id.editTextUserInput)).perform(typeText("SAMPLE"));
}
}
Run Code Online (Sandbox Code Playgroud)
扩展ActivityInstrumentationTestCase2
package sample.com.sample_project_2;
import android.test.ActivityInstrumentationTestCase2;
import static android.support.test.espresso.Espresso.onView;
import static android.support.test.espresso.action.ViewActions.typeText;
import static android.support.test.espresso.matcher.ViewMatchers.withId;
public …Run Code Online (Sandbox Code Playgroud) 我用猴子来压力测试我的应用程序.在https://developer.android.com/studio/test/monkey.html上我读到:
-s <seed> Seed value for pseudo-random number generator. If you re-run the Monkey with the same seed value, it will generate the same sequence of events.
Run Code Online (Sandbox Code Playgroud)
但是当我用相同的种子运行Monkey两次然后比较输出时,我的ACTION_UP和ACTION_DOWN事件的坐标是不一样的.
输出#1
:Monkey: seed=1470246130093 count=50
:AllowPackage: sample1.com.sample_1
:IncludeCategory: android.intent.category.LAUNCHER
:IncludeCategory: android.intent.category.MONKEY
// Event percentages:
// 0: 7.5%
// 1: 5.0%
// 2: 1.0%
// 3: 7.5%
// 4: 50.0%
// 5: -0.0%
// 6: 12.5%
// 7: 7.5%
// 8: 1.0%
// 9: 1.0%
// 10: 0.5%
// 11: 6.5%
:Switch: …Run Code Online (Sandbox Code Playgroud) 我使用aync.parallel并行运行两个函数.这些函数请求RSS提要.然后解析RSS提要并将其添加到我的网页.
但由于某种原因async.parallel运行回调方法而不等到两个函数完成
任务完成后,结果将作为数组传递给最终回调.
我的代码.
require('async').parallel([ function(callback) {
fetchRss(res, bbcOpts); // Needs time to request and parse
callback();
}, function(callback) {
// Very fast.
callback();
} ], function done(err, results) {
if (err) {
throw err;
}
res.end("Done!");
});
Run Code Online (Sandbox Code Playgroud)
事实上我只有"完成!" 在我的网页上.为什么?
我为什么需要打电话res.end()?
在Node.js的文件说:
必须在每个响应上调用方法response.end().
如果我不打电话,我的网页将被"下载"(我的意思是我的浏览器地址栏中的进度条).
javascript parallel-processing node.js progress-bar node-async
我使用VpnService创建了一个TUN设备.为什么TUN接口在我的设备的其他网络接口中具有最高优先级?
更新#1
这是我配置TUN设备的方式:
mInterface = new Builder().setSession(getString(R.string.app_name))
.addAddress("10.0.1.1", 24)
.addRoute("0.0.0.0", 1)
.addRoute("128.0.0.0", 1)
.establish();
Run Code Online (Sandbox Code Playgroud)
更新#2
这是route -n 没有 TUN设备的输出:
shell@m0:/ $ busybox route -n
busybox route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
10.197.55.0 0.0.0.0 255.255.255.0 U 0 0 0 rmnet0
Run Code Online (Sandbox Code Playgroud)
这是的输出route -n 与所述TUN设备:
shell@m0:/ $ busybox route -n
busybox route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
10.0.1.0 0.0.0.0 255.255.255.0 U 0 …Run Code Online (Sandbox Code Playgroud) 我已经在https://docs.oracle.com/javase/7/docs/api/java/util/concurrent/locks/Condition.html上阅读了有关该问题的信息。
这是文档对这两个条件的说明:
我们希望继续等待 put 线程并将线程放在单独的等待集中,以便我们可以使用优化,当缓冲区中的项目或空间可用时,一次只通知单个线程。这可以使用两个 Condition 实例来实现。
因为signal()唤醒了一个线程,所以我可以使用一个条件通知单个线程:
class BoundedBuffer2 {
final Lock lock = new ReentrantLock();
final Condition condition = lock.newCondition();
final Object[] items = new Object[100];
int putptr, takeptr, count;
public void put(Object x) throws InterruptedException {
lock.lock();
try {
while (count == items.length)
condition.await();
items[putptr] = x;
if (++putptr == items.length) putptr = 0;
++count;
condition.signal();
} finally {
lock.unlock();
}
}
public Object take() throws InterruptedException {
lock.lock();
try {
while (count …Run Code Online (Sandbox Code Playgroud) java multithreading synchronization producer-consumer java.util.concurrent
执行我们的一些仪器测试需要很长时间。因此,当我使用gradle connectedAndroidTest.
为什么我不用@Ignore注释这些测试?因为我想稍后使用这里adb shell描述的方式运行它们。
像这样:
运行除特定类中的测试之外的所有测试: adb shell am instrument -w -e notClass com.android.foo.FooTest com.android.foo/android.support.test.runner.AndroidJUnitRunner
如果我将这些测试标记为忽略并编译它们,则根本无法执行它们。
是否可以修改connectedAndroidTest或其他一些任务来达到我的需要?
我需要在我的应用中选择联系人,并希望排除存储在我的SIM卡中的联系人.有可能ACTION_PICK吗?
我读了这个答案并且不知道为什么我应该保留我的服务,活动和自定义视图的名称.但是我应该保留从android.support.v4.app.Fragment派生的类吗?
我还看了一下defualt Proguard配置文件 %SDK_DIR%\sdk\tools\proguard\proguard-android.txt,并没有关于片段的规则.
android ×8
gradle ×1
java ×1
javascript ×1
junit3 ×1
junit4 ×1
localization ×1
monkeyrunner ×1
node-async ×1
node.js ×1
obfuscation ×1
progress-bar ×1
proguard ×1
routing ×1
rx-android ×1
rx-java ×1
string ×1
textview ×1
tun ×1
unit-testing ×1