小编loe*_*chg的帖子

什么是Subject.asObservable有用?

为什么RxJava需要asObservable

从技术上讲,每个主题已经是一个Observable.它的优点是什么,而不仅仅是铸造它

Observable obs = subject;
Run Code Online (Sandbox Code Playgroud)

rx-java

13
推荐指数
1
解决办法
5178
查看次数

如何使用Retrofit添加多个相同/数组参数?

我有一个实例,我需要将多个相同的命名参数传递给服务器(数据数组).

改变它是不可能的.

http://test.com?test[]=1&test[]=2&test[]=3
Run Code Online (Sandbox Code Playgroud)

如何使用RetroFit完成此操作?我看到你可以传递一个值映射,但这并没有帮助,因为键都是相同的.

任何帮助都会很棒...真的希望有一个干净的方法/解决方法,否则我将需要使用另一个api lib并做一个项目重构.

android retrofit

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

使用浏览器意图时传递标题

我想在打开网页时传递一些标题.现在,我正在做类似的事情:) browserIntent = new Intent(Intent.ACTION_VIEW,Uri.parse(data.link)); startActivity(browserIntent;

现在我卡住了,因为我不知道如何使用browserIntent传递标头.我尝试过使用browserIntent.putExtra()但它不起作用.

谁能请帮忙.!!

android http-headers android-intent android-webview

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

JUnit测试中的java.util.ConcurrentModificationException

这是一个在黑暗中的镜头.运行我的robolectric单元测试套件时偶尔会出现以下错误:

java.util.ConcurrentModificationException
  at java.util.LinkedList$ListItr.checkForComodification(LinkedList.java:966)
  at java.util.LinkedList$ListItr.next(LinkedList.java:888)
  at org.robolectric.shadows.ShadowResources.getOverlayedThemeValue(ShadowResources.java:294)
  at org.robolectric.shadows.ShadowResources.findAttributeValue(ShadowResources.java:284)
  at org.robolectric.shadows.ShadowResources.attrsToTypedArray(ShadowResources.java:187)
  at org.robolectric.shadows.ShadowResources.access$000(ShadowResources.java:51)
  at org.robolectric.shadows.ShadowResources$ShadowTheme.obtainStyledAttributes(ShadowResources.java:489)
  at android.content.res.Resources$Theme.obtainStyledAttributes(Resources.java)
  at android.content.Context.obtainStyledAttributes(Context.java:416)
  at android.view.View.__constructor__(View.java:3317)
  at org.robolectric.util.ReflectionHelpers$3.run(ReflectionHelpers.java:144)
  at org.robolectric.util.ReflectionHelpers.traverseClassHierarchy(ReflectionHelpers.java:241)
  at org.robolectric.util.ReflectionHelpers.callInstanceMethod(ReflectionHelpers.java:138)
  at org.robolectric.internal.Shadow.invokeConstructor(Shadow.java:73)
  at org.robolectric.shadows.ShadowView.__constructor__(ShadowView.java:109)
  at android.view.View.<init>(View.java)
  at android.widget.TextView.<init>(TextView.java)
  at com.getbase.floatingactionbutton.FloatingActionsMenu.createLabels(FloatingActionsMenu.java:461)
  at com.getbase.floatingactionbutton.FloatingActionsMenu.onFinishInflate(FloatingActionsMenu.java:447)
  at android.view.LayoutInflater.rInflate(LayoutInflater.java:763)
  at android.view.LayoutInflater.rInflate(LayoutInflater.java:758)
  at android.view.LayoutInflater.rInflate(LayoutInflater.java:758)
  at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
  at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
  at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
  at android.support.v7.app.ActionBarActivityDelegateBase.setContentView(ActionBarActivityDelegateBase.java:228)
  at android.support.v7.app.ActionBarActivity.setContentView(ActionBarActivity.java:102)
  at com.myapp.app.view.activity.MainActivityActivity.onCreate(MainActivityActivity.java:75)
  at android.app.Activity.performCreate(Activity.java:5133)
  at org.robolectric.util.ReflectionHelpers$3.run(ReflectionHelpers.java:144)
  at org.robolectric.util.ReflectionHelpers.traverseClassHierarchy(ReflectionHelpers.java:241)
  at org.robolectric.util.ReflectionHelpers.callInstanceMethod(ReflectionHelpers.java:138)
  at org.robolectric.util.ActivityController$1.run(ActivityController.java:114)
  at org.robolectric.shadows.ShadowLooper.runPaused(ShadowLooper.java:309)
  at org.robolectric.shadows.CoreShadowsAdapter$2.runPaused(CoreShadowsAdapter.java:47)
  at org.robolectric.util.ActivityController.create(ActivityController.java:110)
  at com.myapp.app.BaseActivityRobolectricTest.startActivity(BaseActivityRobolectricTest.java:58)
  at com.myapp.app.BaseActivityRobolectricTest.startActivity(BaseActivityRobolectricTest.java:34)
  at com.myapp.app.view.activity.MainActivityActivityTest.setupActivity(MainActivityActivityTest.java:52) …
Run Code Online (Sandbox Code Playgroud)

java junit android robolectric

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

xml中的Android可绘制形状 - 在正方形中创建一个透明圆圈

有没有办法从xml中的另一个形状中减去或"剪切"一个形状?我想在中心创建一个带有透明圆孔的白色正方形...主要是因为我不想做位图操作来制作圆形图像:).

是的,我知道这个解决方案(如何在Android中创建圆形ImageView?)存在.

在此输入图像描述

android android-xml android-shape

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

enableAutoActivityTracking不会自动跟踪活动?

我目前正在初始化我的Google Analytics跟踪器,如下所示:

GoogleAnalytics analytics = GoogleAnalytics.getInstance(context);
Tracker mGATracker = analytics.newTracker(context.getString(R.string.ga_code));
mGATracker.setSessionTimeout(300);
mGATracker.enableAutoActivityTracking(true);
Run Code Online (Sandbox Code Playgroud)

它适用于发送自定义事件等,虽然我没有看到任何自动活动跟踪(查看行为 - >事件 - > GA中的屏幕).我无法以这种方式启用此设置吗?

android google-analytics-firebase

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

使用RxJava获取对象,转换包含列表,并使用列表

我正在尝试解决的高级问题是使用RxJava Foo将fetched FooContainer(Observable)中包含的FooBar对象列表转换为对象列表.

我的(困惑的)尝试:

fooContainerObservable
  .map(container -> container.getFooList())
  .flatMap(foo -> transformFooToFooBar(foo))
  .collect( /* What do I do here? Is collect the correct thing? Should I be using lift? */)
  .subscribe(fooBarList -> /* Display the list */);
Run Code Online (Sandbox Code Playgroud)

我的困惑(或至少有一点)是将扁平化列表移回列表的步骤.

注意:我正在尝试在Android应用中执行此操作.

android rx-java rx-android

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

Gradle,Robolectric和Espresso

在使用Gradle(Android Studio)构建时,有没有人成功地让Robolectric和Espresso一起工作?

我已经让Robolectric在Android Studio工作,主要是因为Peter Friese的帖子http://www.peterfriese.de/android-testing-with-robolectric/,但由于instrumentRunner/instrumentTest碰撞,我不确定如何整合Espresso .

理想情况下,我有一个如下所示的目录结构:

 |--src
    ??? main (application source - exists)
    ??? test (Robolectric unit tests go here - exists)
    ??? testEspresso [*new*] (espresso tests go here)
Run Code Online (Sandbox Code Playgroud)

我的Gradle + Android知识不是很广泛,而且我不确定这是否真的是一个可行的东西(时间,复杂性和脆弱性水平不是太极端),因为Gradle + Android的当前状态以及它是否是,如何去做.如果它是相关的,我有2种不同的构建风格.

android gradle robolectric android-studio android-espresso

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

Robolectric - screen_action_bar.xml行#-1(抱歉,尚未实现):错误导致类<unknown>

我正在使用Robolectric,我在创建Activity时遇到以下错误.我正在使用2.3快照 - androidTestCompile('org.robolectric:robolectric:2.3-SNAPSHOT')

android.view.InflateException: XML file jar:/Users/user/.m2/repository/org/robolectric/android-all/4.3_r2-robolectric-0/android-all-4.3_r2-robolectric-0.jar!/res/layout/screen_action_bar.xml line #-1 (sorry, not yet implemented): Error inflating class <unknown>
    at android.view.LayoutInflater.createView(LayoutInflater.java:620)
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:758)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:758)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
    at com.android.internal.policy.impl.PhoneWindow.generateLayout(PhoneWindow.java:2823)
    at com.android.internal.policy.impl.PhoneWindow.installDecor(PhoneWindow.java:2886)
    at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:263)
    at android.app.Activity.setContentView(Activity.java:1895)
    at com.company.app.activities.loginjoin.LoginActivity.onCreate(LoginActivity.java:49)
    at android.app.Activity.performCreate(Activity.java:5133)
    at org.fest.reflect.method.Invoker.invoke(Invoker.java:112)
    at org.robolectric.util.ActivityController$1.run(ActivityController.java:147)
    at org.robolectric.shadows.ShadowLooper.runPaused(ShadowLooper.java:265)
    at org.robolectric.util.ActivityController.create(ActivityController.java:144)
    at org.robolectric.util.ActivityController.create(ActivityController.java:154)
    at com.company.app.activities.loginjoin.LoginActivityTest.setup(LoginActivityTest.java:21)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24)
    at org.robolectric.RobolectricTestRunner$2.evaluate(RobolectricTestRunner.java:250)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
    at …
Run Code Online (Sandbox Code Playgroud)

android unit-testing robolectric

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

Android Studio预览:此JVM不支持常量标记15

我正在尝试查看包含一些自定义视图的xml布局的预览(没有什么复杂的...主要是包装器).我收到以下错误:

The following classes could not be instantiated:
- com.app.view.widget.SlidingSwipeRefreshLayout (Open Class, Show Exception, Clear Cache)
- com.app.view.widget.BetterViewAnimator (Open Class, Show Exception, Clear Cache)

java.lang.ClassFormatError: This JVM does not support constant tag 15 in class file <Unknown>
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClassCond(ClassLoader.java:637)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:621)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:471)
    at com.android.tools.idea.rendering.RenderClassLoader.loadClass(RenderClassLoader.java:150)
    at com.android.tools.idea.rendering.RenderClassLoader.loadClassFile(RenderClassLoader.java:125)
    at org.jetbrains.android.uipreview.ModuleClassLoader.loadClassFile(ModuleClassLoader.java:287)
    at com.android.tools.idea.rendering.RenderClassLoader.loadClassFromClassPath(RenderClassLoader.java:118)
    at org.jetbrains.android.uipreview.ModuleClassLoader.loadClassFromModule(ModuleClassLoader.java:202)
    at org.jetbrains.android.uipreview.ModuleClassLoader.loadClassFromModuleOrDependency(ModuleClassLoader.java:136)
    at org.jetbrains.android.uipreview.ModuleClassLoader.load(ModuleClassLoader.java:122)
    at com.android.tools.idea.rendering.RenderClassLoader.findClass(RenderClassLoader.java:53)
    at org.jetbrains.android.uipreview.ModuleClassLoader.findClass(ModuleClassLoader.java:84)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
    at org.jetbrains.android.uipreview.ViewLoader.loadClass(ViewLoader.java:182)
    at org.jetbrains.android.uipreview.ViewLoader.loadView(ViewLoader.java:101)
    at com.android.tools.idea.rendering.LayoutlibCallback.loadView(LayoutlibCallback.java:177)
    at android.view.BridgeInflater.loadCustomView(BridgeInflater.java:207)
    at android.view.BridgeInflater.createViewFromTag(BridgeInflater.java:132)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:482) …
Run Code Online (Sandbox Code Playgroud)

java android android-studio

7
推荐指数
1
解决办法
1235
查看次数