小编Pro*_*kar的帖子

Android Dagger2 + OkHttp + Retrofit依赖循环错误

嘿,我正在使用Dagger2,Retrofit而且OkHttp我正面临依赖循环问题.

提供时OkHttp:

@Provides
@ApplicationScope
OkHttpClient provideOkHttpClient(TokenAuthenticator auth,Dispatcher dispatcher){
    return new OkHttpClient.Builder()
            .connectTimeout(Constants.CONNECT_TIMEOUT, TimeUnit.SECONDS)
            .readTimeout(Constants.READ_TIMEOUT,TimeUnit.SECONDS)
            .writeTimeout(Constants.WRITE_TIMEOUT,TimeUnit.SECONDS)
            .authenticator(auth)
            .dispatcher(dispatcher)
            .build();
}
Run Code Online (Sandbox Code Playgroud)

提供时Retrofit:

@Provides
@ApplicationScope
Retrofit provideRetrofit(Resources resources,Gson gson, OkHttpClient okHttpClient){
    return new Retrofit.Builder()
            .baseUrl(resources.getString(R.string.base_api_url))
            .addConverterFactory(GsonConverterFactory.create(gson))
            .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
            .client(okHttpClient)
            .build();
}
Run Code Online (Sandbox Code Playgroud)

提供时APIService:

@Provides
@ApplicationScope
APIService provideAPI(Retrofit retrofit) {
    return retrofit.create(APIService.class);
}
Run Code Online (Sandbox Code Playgroud)

我的APIService界面:

public interface  APIService {
@FormUrlEncoded
@POST("token")
Observable<Response<UserTokenResponse>> refreshUserToken();

--- other methods like login, register ---

}
Run Code Online (Sandbox Code Playgroud)

我的TokenAuthenticator …

android dependency-injection dagger-2 retrofit2 rx-java2

15
推荐指数
2
解决办法
4188
查看次数

android-app 链接无效

我正在关注 Google I/O 2015 中的这个示例。
演示网站:http : //recipe-app.com/recipe/grilled-potato-salad演示应用程序:http : //search-codelabs.appspot.com/codelabs/安卓深度链接

我的测试:
我已经从上面的链接安装了演示应用程序。我使用 Google 搜索应用程序进行了“烤土豆沙拉”的 Google 搜索,并找到了http://recipe-app.com/recipe/grilled-potato-salad
我希望点击链接会直接打开应用程序,而不是消歧对话框(http://search-codelabs.appspot.com/img/android-deep-linking/img-5.png)。然而,消除歧义对话框仍然令我惊讶。

<link rel="alternate" href="android-app://com.recipe_app/http/recipe-app.com/recipe/grilled-potato-salad" />那个网站上的不是没用吗?

应用程序的清单文件:
```

<uses-permission android:name="android.permission.INTERNET"/>

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/CustomActionBarTheme" >

    <activity
        android:name=".client.HomeActivity"
        android:label="@string/app_name"
        android:exported="true"
        android:theme="@android:style/Theme.Holo.NoActionBar">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

    <activity
        android:name=".client.RecipeActivity"
        android:label="@string/app_name"
        android:exported="true"
        android:launchMode="singleTop"
        android:theme="@android:style/Theme.Holo.NoActionBar">
        <intent-filter android:label="@string/app_name">
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />
            <!-- Accepts URIs that begin with "http://recipe-app.com/recipe" -->
            <data android:scheme="http" …
Run Code Online (Sandbox Code Playgroud)

android deep-linking

6
推荐指数
2
解决办法
1万
查看次数

当应用被杀时,不会调用Firebase onMessageReceived

关于Firebase Cloud Messaging的热门话题一直是onMessageReceived()某些低端设备的方法没有触发Data Payload消息.这是真的.结果如下:

应用程序被杀死场景:

设备获得数据负载:

  1. Nexus 5X:OS 7.1

设备无法获得数据负载:

  1. 小米MI 4C:OS 5.1
  2. 华为LUA-U22:OS 5.1

确保我不从服务器/邮递员发送通知密钥.

我正在寻找解决方案,我从Firebase获得了数据负载,包括所有类型的设备,操作系统以及显然来自API级别15.我的邮递员详细信息如下.

 {
    "registration_ids": ["fC5uxGSRCsg:APA91bHh9fMXQ41LpX6tjjSsBKGrKTWYpzKimLDzvBGSHDPo2pq87JHqogUp2kqrmJi06siG_p6DfgRCim23iFzlBQAIrgtMDqRW4s39zUqv9CzyPqzxVl5PtnHPRDs4OagTuTePNyDI"],
    "data": {
        "title" : "my_custom_value",
        "message" : "tekksdasdasdsa",
         "isBackground" : "",
          "payload" : {


          },
           "timestamp" : "",
            "imageUrl" : "",
     }

}
Run Code Online (Sandbox Code Playgroud)

java android firebase firebase-cloud-messaging

6
推荐指数
1
解决办法
2372
查看次数

工具栏的左侧增加了额外的空间

我在应用程序中使用了自定义工具栏。工具栏的左侧增加了额外的空间。这是我的Xml文件:

<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:id="@+id/customActionBar"
    android:layout_height="wrap_content"
    android:background="@color/titleBar">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="horizontal">

    <ImageButton
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:id="@+id/leftIcon"
        android:src="@drawable/abc_btn_rating_star_on_mtrl_alpha"
        android:background="@android:color/transparent"
        android:layout_weight="0.2"/>

    <TextView
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:id="@+id/actionTitleText"
        android:text="@string/app_name"
        android:textColor="@color/abc_primary_text_disable_only_material_dark"
        android:textSize="@dimen/text_22sp"
        android:padding="@dimen/size_12dip"
        android:gravity="center_horizontal"
        android:layout_weight="0.6"/>

    <ImageButton
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:id="@+id/rightIcon"
        android:src="@drawable/abc_btn_rating_star_on_mtrl_alpha"
        android:background="@android:color/transparent"
        android:layout_weight="0.2"/>
</LinearLayout>


</android.support.v7.widget.Toolbar>
Run Code Online (Sandbox Code Playgroud)

你能帮忙吗?它从屏幕的左边给出了一些边距,但是我没有给出任何边距属性。这是将其膨胀为活动的代码:

 @Override
    public void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

        super.setContentView(R.layout.activity_main);
        baseViewContent = (LinearLayout) findViewById(R.id.main_activity_content_view);
        viewController = new ViewController(this, baseViewContent);
        activity = this;

        // Set a toolbar to replace the action bar.
        android.support.v7.widget.Toolbar toolbar = (android.support.v7.widget.Toolbar) findViewById(R.id.customActionBar);
        setSupportActionBar(toolbar);
Run Code Online (Sandbox Code Playgroud)

android android-toolbar

2
推荐指数
1
解决办法
1208
查看次数

为什么以下程序打印"是"而不是"否"?

为什么以下程序打印"是"而不是"否"?

没有变量初始化为2.

    bool hello = 0;
    int a = 1;
    int b = 3;
    int c = 4;
    int d = 5;

    if (a || b || c || d == 2) {
        hello = 1;
    }

    if (hello == 1) {
        printf("Yes");
    }

    if (hello == 0) {
        printf("No");
    }

    return 0;
}
Run Code Online (Sandbox Code Playgroud)

c boolean

-5
推荐指数
1
解决办法
129
查看次数