有没有办法拦截Windows Phone 8上的http请求?
我有一个PhoneGap应用程序,我想拦截WebView正在做的一些http请求并返回我自己的响应.我正在拦截在Web服务器上请求资产并返回可在本地生成的资产的调用.
在Android中,我可以使用shouldInterceptrequest
在iOS中,我可以使用NSURLProtocol
从我在Windows Phone 8上可以看出,我可以注册我自己的方案来启动我的应用程序,但我不能拦截http请求.有什么东西我错过了吗?
我正在尝试测试GeoFences的位置感知应用程序.我已经获得了多达11次连续成功,但通常会有数十次失败.重新启动设备没有帮助.卸载/重新安装没有帮助.禁用位置,重新启用位置无济于事.更改设备位置准确度设置没有帮助.
我已经在v2.3.4,v4.0.3,v4.4.2,v4.4.4和2 v5.0.1物理设备上进行了测试.其中一个Lollipop设备是具有蜂窝服务的设备.其余设备是SIMless的,仅用于测试.旁注:没有服务的设备很难通过MockLocation设置它们的位置,但是如果他们设法设置它们的位置,他们几乎从不注册围栏入口/出口.
位置正在通过Mock Location更新,但GeoFence不会被任何可靠性触发.
我用谷歌搜索了它.我查看了developer.android.com网站上的文档.我搜索过StackOverflow.事实上,其他人提出的许多建议已在下面的代码中实现.
那么,我如何使用MockLocation可靠地触发我的GeoFence?
import android.location.Location;
import android.location.LocationManager;
public class GeoFenceTester extends ActivityInstrumentationTestCase2<GeoFenceTesterActivity> {
public static final String TAG = GeoFenceTester.class.getSimpleName();
private LocationManager locationManager;
private Activity activityUnderTest;
protected void setUp() throws Exception {
super.setUp();
activityUnderTest = getActivity();
/*
MOCK Locations are required for these tests. If the user has not enabled MOCK Locations
on the device or emulator these tests cannot work.
*/
if (Settings.Secure.getInt(activityUnderTest.getContentResolver(), Settings.Secure.ALLOW_MOCK_LOCATION, 0) == 0) {
throw new RuntimeException("Mock locations are currently disabled …Run Code Online (Sandbox Code Playgroud) android unit-testing geolocation android-location geofencing
詹金斯v2.19
Git插件v2.5.3
在Branches to Build我指定2个分支:
*/develop
Run Code Online (Sandbox Code Playgroud)
和
*/master
Run Code Online (Sandbox Code Playgroud)
这导致了HEAD detached at {git commit hash}.我的gradle构建脚本中有不同的操作,它们使用当前的git分支作为触发器来执行不同的操作.
我怎样才能使这个结帐开发以掌握并掌握掌握而不是分离的HEAD?
我的应用程序中包含一个模块,该模块未通过测试并导致我的 CI 构建失败。
我已尝试使用以下内容排除我的测试app/build.gradle,但未成功排除测试:
android {
sourceSets {
test {
java {
srcDir 'src'
exclude 'com/some/path/**'
}
}
}
// ...
}
Run Code Online (Sandbox Code Playgroud)
或者,我一直在寻找一种以自动方式删除test模块文件夹的方法,但我没有找到任何东西。
我已经从SDK页面修改了这个示例,以从手机中获取所有联系人组并显示它们.但是,我无法弄清楚如何单击其中一个,然后使用Groups._ID执行其他操作.有人可以教我如何在这个列表上获得一个点击/选择监听器吗?
MyListAdapter.java
package com.example.simplelist;
import android.app.ListActivity;
import android.database.Cursor;
import android.os.Bundle;
import android.provider.Contacts.Groups;
import android.widget.ListAdapter;
import android.widget.SimpleCursorAdapter;
public class MyListAdapter extends ListActivity {
@Override
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.custom_list_activity_view);
Cursor mCursor = this.getContentResolver().query(Groups.CONTENT_URI, null, null, null, null);
startManagingCursor(mCursor);
ListAdapter adapter = new SimpleCursorAdapter(this, android.R.layout.two_line_list_item, mCursor, new String[] {Groups.NAME, Groups._ID}, new int[] {android.R.id.text1, android.R.id.text2});
setListAdapter(adapter);
}
}
Run Code Online (Sandbox Code Playgroud)
custom_list_activity_view.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:paddingLeft="8dp"
android:paddingRight="8dp">
<ListView android:id="@id/android:list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#00FF00"
android:layout_weight="1"
android:drawSelectorOnTop="false" android:choiceMode="singleChoice" android:clickable="true" />
<TextView android:id="@id/android:empty"
android:layout_width="fill_parent" …Run Code Online (Sandbox Code Playgroud) 我将Jenkins CI配置为与GitHub一起使用.它成功填充了我的$ {workspace},但我想要构建的实际项目位于repo的子目录中:
https://github.com/androidfu/CodeExamples
从Jenkins内部调用Ant表示它找不到build.xml.好吧,那是因为build.xml实际上存在于$ {workspace}/DeveloperDebugPreferences中.
我正在对未来的工作进行排队,同时还“现在”运行初始工作。20 个项目加入队列后,添加的任何新项目都不再立即运行,我将不得不等待 30 天才能查看它们是否运行;)
将工作项的初始延迟设置为 10 秒(允许的最小值)后,我已经等待了 24 小时以上。
如果我安排第 21 份工作,什么也不会发生。取消 10 秒后运行的前 20 个和第 21 个作业中的任何一个。100% 可重复——重新安排作业 20,没什么。取消作业 21,作业 20 将在 10 秒后运行。
dependencies {
implementation 'androidx.work:work-runtime:2.3.4'
}
fun scheduleTickle(context: Context, item: Item) {
// item.id is the auto-generated primary key from the database
val periodicWorkRequest = PeriodicWorkRequest.Builder(
MessageWorker::class.java,
item.minimumInterval,
TimeUnit.DAYS
).let {
it.setInputData(
Data.Builder()
.putLong("EXTRA_KEY_ITEM_ID", item.id)
.build()
)
it.setConstraints(
Constraints.Builder()
.setRequiredNetworkType(NetworkType.CONNECTED)
.build()
)
it.addTag("com.example.myapp.periodicWork.${item.id}")
it.setInitialDelay(10, TimeUnit.SECONDS)
}.build()
WorkManager.getInstance(context).enqueueUniquePeriodicWork(
item.id.toString(),
ExistingPeriodicWorkPolicy.REPLACE,
periodicWorkRequest
)
}
Run Code Online (Sandbox Code Playgroud) 尝试使用 SpringMVC @ResponseBody 将我的对象作为 JSON 字符串返回时出现以下错误:
org.codehaus.jackson.map.JsonMappingException:没有找到类 com.ResourceResultSetCol 的序列化程序,也没有发现创建 BeanSerializer 的属性(为了避免异常,禁用 SerializationConfig.Feature.FAIL_ON_EMPTY_BEANS))(通过参考链:com.medplus.devops.pdt .server.ResourceResultSet["cols"]->java.util.ArrayList[0])
图结果集.java:
@Controller
@RequestMapping("/pdt")
public class GraphResultSet {
@RequestMapping(value = "/getResourceResultSet", method = RequestMethod.GET)
public @ResponseBody
ResourceResultSet getResourceResultSet(
@RequestParam(value = "resourceId", required = true) int resourceId) {
return new ResourceResultSet(resourceId);
}
}
Run Code Online (Sandbox Code Playgroud)
资源结果集.java:
public class ResourceResultSet implements Serializable {
public String resourceName;
public ArrayList<ResourceResultSetCol> cols;
public ArrayList<ResourceResultSetRow> rows;
ResourceResultSet(int id) {
resourceName = "Graph " + id;
cols = new ArrayList<ResourceResultSetCol>();
cols.add(new ResourceResultSetCol("col1","Timestamp","date"));
cols.add(new ResourceResultSetCol("col2","Value","number"));
int randomNumberOfResults = …Run Code Online (Sandbox Code Playgroud) 所以我试图动态计算将为给定的消息长度发送的SMS消息的数量.SMS消息被分成160个字节(字符)块.我使用MOD 160 <= 1,因为我需要考虑添加和减去文本.出于性能原因,我只想在边界附近进行numMsgs计算:0,1,160,161,320,321,......
问题是在msgBody长度为160时,舍入操作的计算结果为2(160/160 = 1 + 0.5向上舍入).在160 + 1的倍数处,它应该评估为下一个最高整数,因为任何160个字节+ 1个字节等于整个附加消息.
我通过使用OR运算符和== 1 OR == 159来完成这项工作.它正确地递增和递减,但它仅在160 -1的倍数处递减,这是不正确的.
此外,我可以将IF逻辑放在外部逻辑中,如果MOD评估为0(零),则简单地减去1,但这似乎是kludgey,我宁愿学习我可能在我的箭袋中丢失的模式:)
if (msgBody.length() % 160 <= 1) {
numMsgs.setText(Math.round(msgBody.length() / 160 + 0.5));
}
Run Code Online (Sandbox Code Playgroud) android ×6
git ×2
java ×2
jenkins ×2
ant ×1
arraylist ×1
cordova ×1
geofencing ×1
geolocation ×1
gitosis ×1
gradle ×1
jackson ×1
junit ×1
listadapter ×1
listview ×1
math ×1
onselect ×1
react-native ×1
rounding ×1
spring-mvc ×1
unit-testing ×1
webview ×1