如何使用FirebaseInstanceId.getInstance()。deleteInstanceId()?

时间:2016-12-10 09:46:39

标签: java android firebase firebase-cloud-messaging

我想用

删除我的FireBaseInstance
FirebaseInstanceId.getInstance().deleteInstanceId() 

我使用了try / catch块,但是我收到了这个错误:

> W/System.err: java.io.IOException: MAIN_THREAD W/System.err:     at
> com.google.firebase.iid.zzd.zzb(Unknown Source) W/System.err:     at
> com.google.firebase.iid.FirebaseInstanceId.deleteInstanceId(Unknown
> Source) W/System.err:     at
> package.class.onCreate(DatenLadenActivity.java:57)
> W/System.err:     at
> android.app.Activity.performCreate(Activity.java:6272) W/System.err:  
> at
> android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
> W/System.err:     at
> android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2387)
> W/System.err:     at
> android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2494)
> W/System.err:     at
> android.app.ActivityThread.access$900(ActivityThread.java:157)
> W/System.err:     at
> android.app.ActivityThread$H.handleMessage(ActivityThread.java:1356)
> W/System.err:     at
> android.os.Handler.dispatchMessage(Handler.java:102) W/System.err:    
> at android.os.Looper.loop(Looper.java:148) W/System.err:     at
> android.app.ActivityThread.main(ActivityThread.java:5525)
> W/System.err:     at java.lang.reflect.Method.invoke(Native Method)
> W/System.err:     at
> com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:730)
> W/System.err:     at
> com.android.internal.os.ZygoteInit.main(ZygoteInit.java:620)

感谢您的回答并抱歉我的英语不好:)

1 个答案:

答案 0 :(得分:46)

Thread是一个阻止通话。它不能在主线程上调用。如果您只需要调用它进行开发和测试,则可以使用简单的 new Thread(new Runnable() { @Override public void run() { try { FirebaseInstanceId.getInstance().deleteInstanceId(); } catch (IOException e) { e.printStackTrace(); } } }).start();

 jQuery(function() {
  var getWindow = jQuery(window);
  var windowHeight = getWindow.height(); 
  jQuery(window).scroll(function(){
   if(jQuery(window).scrollTop() > windowHeight ){jQuery(".test").fadeIn( 100 );}
   else{jQuery(".test").fadeOut( 100 );}
  });
 });