android - PubNub: Cannot resolve method subscribe -


i new android programming , using pubnub first time. have included .jar file in lib. have imported it.

i following steps given here - http://www.pubnub.com/docs/android-java/pubnub-java-sdk#copy_and_paste_examples

but getting error message. - " cannot resolve method 'subscribe(java.lang.string,anonymous javax.security.auth.callback.callback)'

i using android studio. also, putting entire code in mainactivity. not sure code pubnub goes.

my main activity -

 package com.example....<hidden>;  import android.support.v7.app.actionbaractivity; import android.os.bundle; import android.view.menu; import android.view.menuitem; import android.view.view; import android.widget.textview; import com.parse.parse; import com.parse.parseobject; import com.pubnub.api.pubnub; import com.pubnub.api.pubnuberror; import com.pubnub.api.pubnubexception; import com.pubnub.api.*;   import org.json.*;    import javax.security.auth.callback.callback;    public class mainactivity extends actionbaractivity { private textview testing; pubnub pubnub = new pubnub("<mypubkey>", "<mysubkey>");  @override protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.activity_main)      /* subscribe demo_tutorial channel */     try {         pubnub.subscribe("demo_tutorial", new callback() {             public void successcallback(string channel, object message) {                 system.out.println(message);             }              public void errorcallback(string channel, pubnuberror error) {                 system.out.println(error.geterrorstring());             }         });     } catch (pubnubexception e) {         e.printstacktrace();     }  } 

my gradle -

 dependencies { compile filetree(dir: 'libs', include: ['*.jar']) compile 'com.android.support:appcompat-v7:22.2.0' compile filetree(dir: 'libs', include: 'parse-*.jar') compile filetree(dir: 'libs', include: 'pubnub-*.jar') } 

please let me know how use pubnub if doing wrong.. i.e.

import javax.security.auth.callback.callback; 

there issue. pubnub uses own callback. rest of code looks good, reason says cannot resolved because there no implementation of subscribe takes in string , javax.security.auth.callback.callback.

delete import code , should work since have included com.pubnub.api.*. if explicitly include it, import statement follows:

import com.pubnub.api.callback; 

one other error caused me lot of trouble when starting pubnub on android forgetting request proper internet permissions. sure following lines in manifest after <manifest> tag , before <application> tag:

<uses-permission android:name="android.permission.internet" /> <uses-permission android:name="android.permission.access_network_state" /> <uses-permission android:name="android.permission.access_wifi_state" /> <uses-permission android:name="com.google.android.c2dm.permission.receive" /> 

also, believe gradle import should ok if android studio recognizes functions. make things easier in future, feel free include pubnub's hosted library using following dependency.

compile 'com.pubnub:pubnub:3.7.2'  

best of luck, let me know if have further questions!


Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -