added logs to FacebookActivity.onComplete()
onComplete() is being called but still the activity is not finishing. When you hit back it works as expected. I've tried adding flags to the calling intent, intializing all lifecycle methods and even arranging the order things are called. I have tried these intent flags so far: FLAG_ACTIVITY_NO_HISTORY FLAG_ACTIVITY_NEW_TASK FLAG_ACTIVITY_CLEAR_TASK
@@ -9,8 +9,8 @@
|
|||||||
</attributes>
|
</attributes>
|
||||||
</classpathentry>
|
</classpathentry>
|
||||||
<classpathentry kind="lib" path="/Users/warren/Development/workspace/TravelPost/libs/twitter4j-core-2.1.11.jar"/>
|
<classpathentry kind="lib" path="/Users/warren/Development/workspace/TravelPost/libs/twitter4j-core-2.1.11.jar"/>
|
||||||
<classpathentry kind="src" path="FacebookLib_src"/>
|
|
||||||
<classpathentry kind="src" path="ExceptionHandlerLib_src"/>
|
|
||||||
<classpathentry kind="src" path="LocationLib_src"/>
|
<classpathentry kind="src" path="LocationLib_src"/>
|
||||||
|
<classpathentry kind="src" path="ExceptionHandlerLib_src"/>
|
||||||
|
<classpathentry kind="src" path="FacebookLib_src"/>
|
||||||
<classpathentry kind="output" path="bin"/>
|
<classpathentry kind="output" path="bin"/>
|
||||||
</classpath>
|
</classpath>
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
created FacebookActivity.java and facebookactivity.xml. this activity is designed to assist with context issues during facebook authorization for the initial authorization.
|
added logs to FacebookActivity.onComplete()
|
||||||
also modified TravelPostMain.java to fire an intent for this activity.
|
|
||||||
|
|
||||||
currently works. facebook authorized. saves the settings. only issue is you get a black screen aftwords. if you hit back all is good.
|
onComplete() is being called but still the activity is not finishing. When you hit back it works as expected.
|
||||||
|
I've tried adding flags to the calling intent, intializing all lifecycle methods and even arranging the order things are called.
|
||||||
|
|
||||||
TODO:
|
I have tried these intent flags so far:
|
||||||
log the onComplete method in facebookactivity to see what is happening.
|
FLAG_ACTIVITY_NO_HISTORY
|
||||||
twitter authorization.
|
FLAG_ACTIVITY_NEW_TASK
|
||||||
finish widget and posting to sites.
|
FLAG_ACTIVITY_CLEAR_TASK
|
||||||
@@ -20,11 +20,13 @@ public final class R {
|
|||||||
public static final int icon=0x7f020002;
|
public static final int icon=0x7f020002;
|
||||||
public static final int logoidea3=0x7f020003;
|
public static final int logoidea3=0x7f020003;
|
||||||
public static final int needle=0x7f020004;
|
public static final int needle=0x7f020004;
|
||||||
public static final int skyhook_logo=0x7f020005;
|
public static final int notification=0x7f020005;
|
||||||
public static final int skyhook_logo_alpha=0x7f020006;
|
public static final int skyhook_logo=0x7f020006;
|
||||||
public static final int skyhook_logo_alpha_small=0x7f020007;
|
public static final int skyhook_logo_alpha=0x7f020007;
|
||||||
public static final int tc_logo_complete=0x7f020008;
|
public static final int skyhook_logo_alpha_small=0x7f020008;
|
||||||
public static final int user=0x7f020009;
|
public static final int tc_logo_complete=0x7f020009;
|
||||||
|
public static final int user=0x7f02000a;
|
||||||
|
public static final int widget=0x7f02000b;
|
||||||
}
|
}
|
||||||
public static final class id {
|
public static final class id {
|
||||||
public static final int skyhook_img=0x7f070000;
|
public static final int skyhook_img=0x7f070000;
|
||||||
|
|||||||
@@ -20,11 +20,13 @@ public final class R {
|
|||||||
public static final int icon=0x7f020002;
|
public static final int icon=0x7f020002;
|
||||||
public static final int logoidea3=0x7f020003;
|
public static final int logoidea3=0x7f020003;
|
||||||
public static final int needle=0x7f020004;
|
public static final int needle=0x7f020004;
|
||||||
public static final int skyhook_logo=0x7f020005;
|
public static final int notification=0x7f020005;
|
||||||
public static final int skyhook_logo_alpha=0x7f020006;
|
public static final int skyhook_logo=0x7f020006;
|
||||||
public static final int skyhook_logo_alpha_small=0x7f020007;
|
public static final int skyhook_logo_alpha=0x7f020007;
|
||||||
public static final int tc_logo_complete=0x7f020008;
|
public static final int skyhook_logo_alpha_small=0x7f020008;
|
||||||
public static final int user=0x7f020009;
|
public static final int tc_logo_complete=0x7f020009;
|
||||||
|
public static final int user=0x7f02000a;
|
||||||
|
public static final int widget=0x7f02000b;
|
||||||
}
|
}
|
||||||
public static final class id {
|
public static final class id {
|
||||||
public static final int skyhook_img=0x7f070000;
|
public static final int skyhook_img=0x7f070000;
|
||||||
|
|||||||
@@ -20,11 +20,13 @@ public final class R {
|
|||||||
public static final int icon=0x7f020002;
|
public static final int icon=0x7f020002;
|
||||||
public static final int logoidea3=0x7f020003;
|
public static final int logoidea3=0x7f020003;
|
||||||
public static final int needle=0x7f020004;
|
public static final int needle=0x7f020004;
|
||||||
public static final int skyhook_logo=0x7f020005;
|
public static final int notification=0x7f020005;
|
||||||
public static final int skyhook_logo_alpha=0x7f020006;
|
public static final int skyhook_logo=0x7f020006;
|
||||||
public static final int skyhook_logo_alpha_small=0x7f020007;
|
public static final int skyhook_logo_alpha=0x7f020007;
|
||||||
public static final int tc_logo_complete=0x7f020008;
|
public static final int skyhook_logo_alpha_small=0x7f020008;
|
||||||
public static final int user=0x7f020009;
|
public static final int tc_logo_complete=0x7f020009;
|
||||||
|
public static final int user=0x7f02000a;
|
||||||
|
public static final int widget=0x7f02000b;
|
||||||
}
|
}
|
||||||
public static final class id {
|
public static final class id {
|
||||||
public static final int skyhook_img=0x7f070000;
|
public static final int skyhook_img=0x7f070000;
|
||||||
|
|||||||
@@ -20,11 +20,13 @@ public final class R {
|
|||||||
public static final int icon=0x7f020002;
|
public static final int icon=0x7f020002;
|
||||||
public static final int logoidea3=0x7f020003;
|
public static final int logoidea3=0x7f020003;
|
||||||
public static final int needle=0x7f020004;
|
public static final int needle=0x7f020004;
|
||||||
public static final int skyhook_logo=0x7f020005;
|
public static final int notification=0x7f020005;
|
||||||
public static final int skyhook_logo_alpha=0x7f020006;
|
public static final int skyhook_logo=0x7f020006;
|
||||||
public static final int skyhook_logo_alpha_small=0x7f020007;
|
public static final int skyhook_logo_alpha=0x7f020007;
|
||||||
public static final int tc_logo_complete=0x7f020008;
|
public static final int skyhook_logo_alpha_small=0x7f020008;
|
||||||
public static final int user=0x7f020009;
|
public static final int tc_logo_complete=0x7f020009;
|
||||||
|
public static final int user=0x7f02000a;
|
||||||
|
public static final int widget=0x7f02000b;
|
||||||
}
|
}
|
||||||
public static final class id {
|
public static final class id {
|
||||||
public static final int skyhook_img=0x7f070000;
|
public static final int skyhook_img=0x7f070000;
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 4.0 KiB After Width: | Height: | Size: 5.1 KiB |
BIN
TravelPost/res/drawable-hdpi/notification.png
Normal file
|
After Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.9 KiB |
BIN
TravelPost/res/drawable-ldpi/notification.png
Normal file
|
After Width: | Height: | Size: 618 B |
|
Before Width: | Height: | Size: 2.5 KiB After Width: | Height: | Size: 3.0 KiB |
BIN
TravelPost/res/drawable-mdpi/notification.png
Normal file
|
After Width: | Height: | Size: 764 B |
BIN
TravelPost/res/drawable/widget.png
Normal file
|
After Width: | Height: | Size: 8.5 KiB |
@@ -1,11 +1,5 @@
|
|||||||
package com.TwentyCodes.android.TravelPost.SocialSites;
|
package com.TwentyCodes.android.TravelPost.SocialSites;
|
||||||
|
|
||||||
import com.TwentyCodes.android.TravelPost.R;
|
|
||||||
import com.TwentyCodes.android.TravelPost.Debug.Debug;
|
|
||||||
import com.facebook.android.DialogError;
|
|
||||||
import com.facebook.android.Facebook.DialogListener;
|
|
||||||
import com.facebook.android.FacebookError;
|
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
@@ -13,6 +7,12 @@ import android.os.Bundle;
|
|||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import com.TwentyCodes.android.TravelPost.R;
|
||||||
|
import com.TwentyCodes.android.TravelPost.Debug.Debug;
|
||||||
|
import com.facebook.android.DialogError;
|
||||||
|
import com.facebook.android.Facebook.DialogListener;
|
||||||
|
import com.facebook.android.FacebookError;
|
||||||
|
|
||||||
public class FacebookActivity extends Activity {
|
public class FacebookActivity extends Activity {
|
||||||
|
|
||||||
private static final String AUTHORIZED = "authorized"; //key for shared prefs showing how many social sites are added
|
private static final String AUTHORIZED = "authorized"; //key for shared prefs showing how many social sites are added
|
||||||
@@ -39,13 +39,42 @@ public class FacebookActivity extends Activity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void onComplete() {
|
public void onComplete() {
|
||||||
mFb = null;
|
if (Debug.LOGGING)
|
||||||
mFacebookPrefs = null;
|
Log.i(TAG, "onComplete()");
|
||||||
mSettingsPrefs = null;
|
|
||||||
this.finishActivity(RESULT_OK);
|
this.finishActivity(RESULT_OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPause() {
|
||||||
|
if (Debug.LOGGING)
|
||||||
|
Log.i(TAG, "onPause()");
|
||||||
|
super.onPause();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStop() {
|
||||||
|
if (Debug.LOGGING)
|
||||||
|
Log.i(TAG, "onStop()");
|
||||||
|
super.onStop();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStart() {
|
||||||
|
if (Debug.LOGGING)
|
||||||
|
Log.i(TAG, "onStart()");
|
||||||
|
super.onStart();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onRestart() {
|
||||||
|
if (Debug.LOGGING)
|
||||||
|
Log.i(TAG, "onRestart()");
|
||||||
|
super.onRestart();
|
||||||
|
}
|
||||||
|
|
||||||
public void onDestroy() {
|
public void onDestroy() {
|
||||||
|
if (Debug.LOGGING)
|
||||||
|
Log.i(TAG, "onDestroy()");
|
||||||
mFb = null;
|
mFb = null;
|
||||||
mFacebookPrefs = null;
|
mFacebookPrefs = null;
|
||||||
mSettingsPrefs = null;
|
mSettingsPrefs = null;
|
||||||
@@ -81,18 +110,24 @@ public class FacebookActivity extends Activity {
|
|||||||
FacebookEvents.onLoginError(error.getMessage());
|
FacebookEvents.onLoginError(error.getMessage());
|
||||||
if (Debug.LOGGING)
|
if (Debug.LOGGING)
|
||||||
Log.e(TAG, "LoginDialogListener.error: " + error.getMessage());
|
Log.e(TAG, "LoginDialogListener.error: " + error.getMessage());
|
||||||
|
FacebookActivity fa = new FacebookActivity();
|
||||||
|
fa.onComplete();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onError(DialogError error) {
|
public void onError(DialogError error) {
|
||||||
FacebookEvents.onLoginError(error.getMessage());
|
FacebookEvents.onLoginError(error.getMessage());
|
||||||
if (Debug.LOGGING)
|
if (Debug.LOGGING)
|
||||||
Log.e(TAG, "LoginDialogListener.error: " + error.getMessage());
|
Log.e(TAG, "LoginDialogListener.error: " + error.getMessage());
|
||||||
|
FacebookActivity fa = new FacebookActivity();
|
||||||
|
fa.onComplete();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onCancel() {
|
public void onCancel() {
|
||||||
FacebookEvents.onLoginError("Action Canceled");
|
FacebookEvents.onLoginError("Action Canceled");
|
||||||
if (Debug.LOGGING)
|
if (Debug.LOGGING)
|
||||||
Log.e(TAG, "LoginDialogListener.login cancelled");
|
Log.e(TAG, "LoginDialogListener.login cancelled");
|
||||||
|
FacebookActivity fa = new FacebookActivity();
|
||||||
|
fa.onComplete();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package com.TwentyCodes.android.TravelPost;
|
package com.TwentyCodes.android.TravelPost;
|
||||||
|
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.content.Context;
|
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
@@ -25,7 +24,6 @@ public class TravelPostMain extends PreferenceActivity implements OnPreferenceCl
|
|||||||
|
|
||||||
private static PreferenceCategory mSocialSites;
|
private static PreferenceCategory mSocialSites;
|
||||||
private static SharedPreferences mFacebookPrefs;
|
private static SharedPreferences mFacebookPrefs;
|
||||||
private static Context mAppCtx;
|
|
||||||
|
|
||||||
|
|
||||||
/** Called when the activity is first created. */
|
/** Called when the activity is first created. */
|
||||||
@@ -38,11 +36,15 @@ public class TravelPostMain extends PreferenceActivity implements OnPreferenceCl
|
|||||||
/* Sets default uncaught exception handler */
|
/* Sets default uncaught exception handler */
|
||||||
Thread.setDefaultUncaughtExceptionHandler(new ExceptionHandler(this));
|
Thread.setDefaultUncaughtExceptionHandler(new ExceptionHandler(this));
|
||||||
|
|
||||||
mAppCtx = this.getApplicationContext();
|
|
||||||
|
|
||||||
this.initActivity();
|
this.initActivity();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
|
||||||
|
if (Debug.LOGGING)
|
||||||
|
Log.i(TAG, "onActivityResult()");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method initializes the xml layout and all variables needed for that layout
|
* This method initializes the xml layout and all variables needed for that layout
|
||||||
*/
|
*/
|
||||||
@@ -75,11 +77,11 @@ public class TravelPostMain extends PreferenceActivity implements OnPreferenceCl
|
|||||||
* If both prove true it creates the preference
|
* If both prove true it creates the preference
|
||||||
*/
|
*/
|
||||||
if (site.equals(FACEBOOK) && mFacebookPrefs.getBoolean(AUTHORIZED, false)) {
|
if (site.equals(FACEBOOK) && mFacebookPrefs.getBoolean(AUTHORIZED, false)) {
|
||||||
if (mSocialSites.findPreference(mAppCtx.getString(R.string.facebook)) == null) {
|
if (mSocialSites.findPreference(this.getString(R.string.facebook)) == null) {
|
||||||
createPreference(R.string.facebook);
|
createPreference(R.string.facebook);
|
||||||
}
|
}
|
||||||
} else if (site.equals(TWITTER) && mAppCtx.getSharedPreferences(TWITTER, 0).getBoolean(AUTHORIZED, false)) {
|
} else if (site.equals(TWITTER) && this.getSharedPreferences(TWITTER, 0).getBoolean(AUTHORIZED, false)) {
|
||||||
if (mSocialSites.findPreference(mAppCtx.getString(R.string.twitter)) == null) {
|
if (mSocialSites.findPreference(this.getString(R.string.twitter)) == null) {
|
||||||
createPreference(R.string.twitter);
|
createPreference(R.string.twitter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -116,8 +118,9 @@ public class TravelPostMain extends PreferenceActivity implements OnPreferenceCl
|
|||||||
Log.i(TAG, "addSocialSite.site" + site);
|
Log.i(TAG, "addSocialSite.site" + site);
|
||||||
|
|
||||||
if (site.equals(FACEBOOK)) {
|
if (site.equals(FACEBOOK)) {
|
||||||
Intent intent = new Intent(this, com.TwentyCodes.android.TravelPost.SocialSites.FacebookActivity.class);
|
Intent intent = new Intent(this.getApplicationContext(), com.TwentyCodes.android.TravelPost.SocialSites.FacebookActivity.class);
|
||||||
this.startActivityForResult(intent, 0);
|
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||||
|
this.startActivityForResult(intent, 1010);
|
||||||
} else if (site.equals(TWITTER)) {
|
} else if (site.equals(TWITTER)) {
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -183,12 +186,12 @@ public class TravelPostMain extends PreferenceActivity implements OnPreferenceCl
|
|||||||
* @param id - auto generated id of title of preference. (ex: R.string.facebook)
|
* @param id - auto generated id of title of preference. (ex: R.string.facebook)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
protected void createPreference(int id) {
|
private void createPreference(int id) {
|
||||||
if (Debug.LOGGING)
|
if (Debug.LOGGING)
|
||||||
Log.i(TAG, "createPreference: " + id);
|
Log.i(TAG, "createPreference: " + id);
|
||||||
Preference pref = new Preference(mAppCtx);
|
Preference pref = new Preference(this);
|
||||||
pref.setTitle(mAppCtx.getString(id));
|
pref.setTitle(this.getString(id));
|
||||||
pref.setKey(mAppCtx.getString(id));
|
pref.setKey(this.getString(id));
|
||||||
mSocialSites.addPreference(pref);
|
mSocialSites.addPreference(pref);
|
||||||
pref.setOnPreferenceClickListener(this);
|
pref.setOnPreferenceClickListener(this);
|
||||||
}
|
}
|
||||||
|
|||||||