Reputation: 2186
I'm creating a deezer module for titanium.
I have a problem when visualizing the login message.
here's my DeezerAndroidModule.java
(or a significant part of it)
@Kroll.module(name="DeezerAndroidModule", id="deezer.android")
public class DeezerAndroidModuleModule extends KrollModule
{
private static final String TAG = "DeezerAndroidModuleModule";
private final String APP_ID = "xxx";
private final static String[] PERMISSIONS = new String[]{"basic_access","offline_access","email"};
private DeezerInterface deezerInterface;
private DeezerConnect connection;
{...}
@Kroll.method
public void loginDeezer()
{
connection.authorize(deezerInterface, PERMISSIONS, new ReconnectDialogHandler());
}
@Kroll.method @Kroll.getProperty
public String userId()
{
DeezerRequest request = new DeezerRequest( "/user/me" );
String result = null;
try {
result = connection.requestSync( request );
}//try
catch( MalformedURLException ex ) {
}//catch
catch( IOException ex ) {
}//catch
catch (OAuthException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (DeezerError e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return result;
}
{...}
class ReconnectDialogHandler implements DialogListener {
@Override
public void onComplete(final Bundle values) {
SessionStore sessionStore = new SessionStore();
sessionStore.save( connection, deezerInterface );
}//met
@Override
public void onDeezerError(final DeezerError deezerError) {
}//met
@Override
public void onError(final DialogError dialogError) {
}//met
@Override
public void onCancel() {
}//met
@Override
public void onOAuthException(OAuthException oAuthException) {
}//met
}
the problem is that when I call loginDeezer()
function, the application throws a generic Java Exception
without prompting the login view...
here's a logcat caption
W/System.err( 6737): java.lang.NullPointerException
W/System.err( 6737): at org.apache.harmony.luni.internal.net.www.protocol.https.HttpsURLConnectionImpl$HttpsEngine.makeSslConnection(HttpsURLConnectionImpl.java:412)
W/System.err( 6737): at org.apache.harmony.luni.internal.net.www.protocol.https.HttpsURLConnectionImpl$HttpsEngine.makeConnection(HttpsURLConnectionImpl.java:378)
W/System.err( 6737): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.retrieveResponse(HttpURLConnectionImpl.java:1018)
W/System.err( 6737): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:512)
W/System.err( 6737): at org.apache.harmony.luni.internal.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:258)
W/System.err( 6737): at com.deezer.sdk.b.a(Unknown Source)
W/System.err( 6737): at com.deezer.sdk.b.a(Unknown Source)
W/System.err( 6737): at com.deezer.sdk.DeezerConnectImpl.requestSync(Unknown Source)
W/System.err( 6737): at deezer.android.DeezerAndroidModuleModule.userId(DeezerAndroidModuleModule.java:84)
W/System.err( 6737): at org.appcelerator.kroll.runtime.v8.V8Object.nativeFireEvent(Native Method)
W/System.err( 6737): at org.appcelerator.kroll.runtime.v8.V8Object.fireEvent(V8Object.java:64)
W/System.err( 6737): at org.appcelerator.kroll.KrollProxy.doFireEvent(KrollProxy.java:835)
W/System.err( 6737): at org.appcelerator.kroll.KrollProxy.handleMessage(KrollProxy.java:1059)
W/System.err( 6737): at android.os.Handler.dispatchMessage(Handler.java:95)
W/System.err( 6737): at android.os.Looper.loop(Looper.java:130)
W/System.err( 6737): at org.appcelerator.kroll.KrollRuntime$KrollRuntimeThread.run(KrollRuntime.java:112)
what's not correct in my code?
Upvotes: 1
Views: 353
Reputation: 2186
I solved the problem, thanks to XGouchet, just using Activities:
in DeezerModule
@Kroll.method
public void loginDeezer()
{
TiApplication appContext = TiApplication.getInstance();
Activity act = appContext.getCurrentActivity();
Intent myIntent = new Intent(act, DeezerInterface.class);
act.startActivity(myIntent);
}
and the DeezerInterface activity class would be this
Upvotes: 1