我正在尝试将基本身份验证(用户名和密码)添加到Retrofit OkHttp客户端.这是我到目前为止的代码:
private static Retrofit createMMSATService(String baseUrl, String user, String pass) {
HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
interceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
OkHttpClient client = new OkHttpClient.Builder().addInterceptor(interceptor).build();
Retrofit retrofit = new Retrofit.Builder()
.baseUrl(baseUrl)
.client(client)
.addConverterFactory(GsonConverterFactory.create())
.build();
return retrofit;
}
Run Code Online (Sandbox Code Playgroud)
我正在使用Retrofit 2.2,本教程建议使用AuthenticationInterceptor
,但此类不可用.添加凭据的正确位置在哪里?我是否必须将它们添加到我的拦截器,客户端或Retrofit对象中?我该怎么做?
我正在尝试在Android Studio中通过网络进行调试.我通过端口5555连接,通常可以逐步通过断点.但是执行一行代码通常需要几分钟,而另一件事是我没有看到任何没有成员的变量.我所看到的只是this
对象,但方法中没有变量.我该如何启用它?
正如您所看到的,我在方法中,并且至少初始化了活动对象,但它在变量监视器中不可见.
更新:
使用USB调试时问题仍然存在.没有局部变量可见,即使在调试时尝试计算表达式时也是如此:
Android Studio 2.1,Gradle 2.1.0,Java 1.8
我正在尝试自动更改一组图标的颜色.每个图标都有一个白色填充图层,另一个图标是透明的.这是一个例子:(在这种情况下它是绿色的,只是为了让它可见)
我试着做以下事情:
private static BufferedImage colorImage(BufferedImage image) {
int width = image.getWidth();
int height = image.getHeight();
for (int xx = 0; xx < width; xx++) {
for (int yy = 0; yy < height; yy++) {
Color originalColor = new Color(image.getRGB(xx, yy));
System.out.println(xx + "|" + yy + " color: " + originalColor.toString() + "alpha: "
+ originalColor.getAlpha());
if (originalColor.equals(Color.WHITE) && originalColor.getAlpha() == 255) {
image.setRGB(xx, yy, Color.BLUE.getRGB());
}
}
}
return image;
}
Run Code Online (Sandbox Code Playgroud)
我遇到的问题是我得到的每个像素都具有相同的值:
32|18 color: java.awt.Color[r=255,g=255,b=255]alpha: 255
Run Code Online (Sandbox Code Playgroud)
所以我的结果只是一个彩色的方块.如何才能实现仅更改非透明部件的颜色?为什么所有像素都具有相同的alpha值?我猜这是我的主要问题:没有正确读取alpha值.
我们即将更新我们的App Android API 26.在有关广播接收器的文档中,它说明了这一点
针对Android 8.0或更高版本的应用无法再在其清单中注册隐式广播的广播接收器
隐式广播接收器被描述为
没有专门针对该应用的广播.例如,ACTION_PACKAGE_REPLACED
所以我认为这android.intent.action.BOOT_COMPLETED
被认为是一个隐含的接收者.
此外,它声明隐式接收器必须Activity
通过使用注册Context.registerReceiver()
.但对于正在倾听BOOT_COMPLETED
事件的接收器来说,这是没有意义的.
处理这个问题的正确方法是什么?我可以把这个接收器放在我的清单中吗?
我正在尝试使用Azure构建一个Application offline sync
并遵循该教程
现在offline storage
效果很好,但没有项目添加到服务器上,但有以下异常:
Error syncAsync com.microsoft.windowsazure.mobileservices.table.sync.push.MobileServicePushFailedException
java.util.concurrent.ExecutionException: com.microsoft.windowsazure.mobileservices.table.sync.push.MobileServicePushFailedException
at com.google.common.util.concurrent.AbstractFuture$Sync.getValue(AbstractFuture.java:299)
at com.google.common.util.concurrent.AbstractFuture$Sync.get(AbstractFuture.java:286)
at com.google.common.util.concurrent.AbstractFuture.get(AbstractFuture.java:116)
at irisrecognition.example.com.irisrecognition.util.ItemManager$5.doInBackground(ItemManager.java:237)
at irisrecognition.example.com.irisrecognition.util.ItemManager$5.doInBackground(ItemManager.java:232)
at android.os.AsyncTask$2.call(AsyncTask.java:288)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:818)
Caused by: com.microsoft.windowsazure.mobileservices.table.sync.push.MobileServicePushFailedException
at com.microsoft.windowsazure.mobileservices.table.sync.MobileServiceSyncContext.pushOperations(MobileServiceSyncContext.java:939)
at com.microsoft.windowsazure.mobileservices.table.sync.MobileServiceSyncContext.consumePushSR(MobileServiceSyncContext.java:834)
at com.microsoft.windowsazure.mobileservices.table.sync.MobileServiceSyncContext.access$1100(MobileServiceSyncContext.java:85)
at com.microsoft.windowsazure.mobileservices.table.sync.MobileServiceSyncContext$PushSyncRequestConsumer.run(MobileServiceSyncContext.java:1127)
Run Code Online (Sandbox Code Playgroud)
这是代码 onCreate()
try {
mClient = new MobileServiceClient(
Constants.ROOT_URL,
"kfogvaexzeDLYyPbRmBiHxQEBUYpku30",
this).withFilter(new ProgressFilter());
initLocalStore().get();
syncAsync();
refreshItemsFromTable();
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
Run Code Online (Sandbox Code Playgroud)
还有一些......
private AsyncTask<Void, …
Run Code Online (Sandbox Code Playgroud) 我正在将我的应用程序与以下意图过滤器一起使用:
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="*.myhost.com"
android:pathPattern=".*"
android:scheme="https" />
</intent-filter>
Run Code Online (Sandbox Code Playgroud)
我想在我们的应用程序中打开与该域的所有链接,除了一个特定的子域,例如
subdomain.myhost.com
Run Code Online (Sandbox Code Playgroud)
如何排除此处的子域?
out/target/common/obj/PACKAGING/public_api.txt:4316: error 5: Added public field android.app.admin.DevicePolicyManager.PASSWORD_QUALITY_MOVEMENT
******************************
You have tried to change the API from what has been previously approved.
To make these errors go away, you have two choices:
1) You can add "@hide" javadoc comments to the methods, etc. listed in the
errors above.
2) You can update current.txt by executing the following command:
make update-api
To submit the revised current.txt to the main Android repository,
you will need approval.
******************************
Run Code Online (Sandbox Code Playgroud)
所以我试着在我的成员变量中添加@hide注释,但它只会给我另一个错误:
frameworks/base/core/java/android/app/admin/DevicePolicyManager.java:233: cannot find symbol
symbol …
Run Code Online (Sandbox Code Playgroud) 我试图在我的C++代码中读取图像
LOGD("Loading image '%s' ...\n", (*inFile).c_str());;
Mat img = imread(*inFile, CV_LOAD_IMAGE_GRAYSCALE);
CV_Assert(img.data != 0);
Run Code Online (Sandbox Code Playgroud)
并获得以下输出:
09-25 17:08:24.798: D/IRISREC(12120): Loading image '/data/data/com.example.irisrec/files/input/osoba1.jpg' ...
09-25 17:08:24.798: E/cv::error()(12120): OpenCV Error: Assertion failed (img.data != 0) in int wahet_main(int, char**), file jni/wahet.cpp, line 4208
Run Code Online (Sandbox Code Playgroud)
该文件存在.但奇怪的是,如果我尝试使用根文件浏览器预览图像,它只是黑色.我手动复制了文件.
编辑:
该代码在Windows下以.png和.jpg格式正常工作.我只是想将现有的Iris C++ C++项目移植到Android上.
我需要使用这两个元素,这就是我目前所拥有的:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v4.widget.DrawerLayout xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:openDrawer="start">
<android.support.design.widget.NavigationView
android:id="@+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:headerLayout="@layout/nav_header_main"
app:menu="@menu/activity_main_drawer" />
</android.support.v4.widget.DrawerLayout>
<android.support.design.widget.BottomNavigationView
android:id="@+id/bottom_navigation_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="@color/colorAccent"
app:menu="@menu/menu_bottom" />
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
我的问题是BottomNavigationView
位于 前面NavigationView
,但情况不应该如此(我说的是 y 索引)。我也尝试使用 aCoordinatorLayout
代替,但随后卡BottomNavigationView
在显示器的顶部。
我想从selectOneMenu中选择另一个Skin时更改inputTexts的值.一切都很顺利,我的转换器从菜单中返回正确的对象,但inputTexts没有更新.
<h:form>
<h:selectOneMenu id="dropdownSkin"
value="#{helloBean.currentSkin}" defaultLabel="Select a skin.."
valueChangeListener="#{helloBean.skinValueChanged}" immediate="true"
onchange="this.form.submit()" converter="SkinConverter" >
<f:selectItems value="#{helloBean.mySkinsSI}" var="c"
itemValue="#{c.value}" />
</h:selectOneMenu>
<br />
<h:inputText id="name" value="#{helloBean.currentSkin.title}"></h:inputText>
<br />
<h:inputText id="tcolor" value="#{helloBean.currentSkin.titleBar.textColor}"></h:inputText>
<br />
<h:inputText id="bcolor" value="#{helloBean.currentSkin.titleBar.backgroundColorStart}"></h:inputText>
</h:form>
Run Code Online (Sandbox Code Playgroud)
这是我的Bean的样子.我调试它并正确设置了Object currentSkin.现在我需要知道如何更新文本字段内容.
@ManagedBean
@SessionScoped
public class HelloBean implements Serializable {
private static final long serialVersionUID = 1L;
private List<ExtendedSkin> mySkins;
private List<SelectItem> mySkinsSI;
private ExtendedSkin currentSkin;
public void skinValueChanged(ValueChangeEvent e) {
currentSkin = (ExtendedSkin) e.getNewValue();
FacesContext.getCurrentInstance().renderResponse();
}
public List<ExtendedSkin> getMySkins() {
mySkins = XMLParser.readExtendedSkins();
return …
Run Code Online (Sandbox Code Playgroud)