使用FormBody,okhttpcliient和R android studio时出错

时间:2017-02-11 06:23:49

标签: java android android-studio

以下是我收到错误:

无法解析符号' FormBody' 并且无法解析符号' OkhttpClient'

我已添加到我的app build gradle:

     compile 'com.squareup.okhttp3:okhttp:3.6.0'

  private void registerToken(String token){

    OkHttpClient client = new OkhttpClient();
    RequestBody body = new FormBody.Builder()
            .add("Token",token)
            .build();

在使用' R'时,我也无法解析符号。符号,这是代码:

  import android.app.NotificationManager;
  import android.app.PendingIntent;
  import android.content.Intent;
  import android.support.v4.app.NotificationCompat;
  import com.google.firebase.messaging.RemoteMessage;

 /**
 * Created by Diego Fabiano on 2/11/2017.
  */

 public class FirebaseMessagingService   extends        com.google.firebase.messaging.FirebaseMessagingService {

@Override
public void onMessageReceived(RemoteMessage remoteMessage) {

    showNotification(remoteMessage.getData().get("message"));
}

private void showNotification (String message) {

    Intent i = new Intent(this,questions_activity.class);
    i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);

    PendingIntent pendingIntent = PendingIntent.getActivity(this,0,i, PendingIntent.FLAG_UPDATE_CURRENT);

        NotificationCompat.Builder builder = new NotificationCompat.Builder(this)
            .setAutoCancel(true)
            .setContentTitle("New Question received")
            .setContentText(message)
            .setSmallIcon(R.drawable.commmon_google_signin_btn_icon_dark)
            .setContentIntent(pendingIntent);

    NotificationManager manager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
    manager.notify(0,builder.build());
    }

0 个答案:

没有答案