public class MyFaceBook extends Activity {
// private static final String APP_ID = "406323072743416";
//private static final String APP_ID = "233080276760918";
private static final String[] PERMISSIONS = new String[]"email","user_birthday","user_relationships","user_about_me","user_relationship_details","read_stream","publish_stream"};
// private static Facebook facebook;
public String messageToPost;
String info1,link_attack;
String value = info1;
String fb_msg = "";
String login_response;
int CheckIn = 0;
ProgressDialog PD;
String response1;
static Facebook facebook = new Facebook("265162440263509");
private SharedPreferences mPrefs;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// facebook = new Facebook(APP_ID);
fb_msg = getIntent().getExtras().getString("FbMsg");
login_response = getIntent().getExtras().getString("Fb_Value");
CheckIn = getIntent().getExtras().getInt("CheckIn");
mPrefs = getPreferences(MODE_PRIVATE);
String access_token = mPrefs.getString("access_token", null);
long expires = mPrefs.getLong("access_expires", 0);
if(access_token != null) {
facebook.setAccessToken(access_token);
}
if(expires != 0) {
facebook.setAccessExpires(expires);
}
if (! facebook.isSessionValid()) {
Log.d("A1","1");
loginAndPostToWall();
}
else if(CheckIn == 3){
SplashScreenDMN.db.update_CheckTwitterFacebookFour("FaceBook_Flag_Value",1,CheckIn);
Login_funcation();
}
else if(CheckIn == 1 || CheckIn == 2 ){
SplashScreenDMN.db.update_CheckTwitterFacebookFour("FaceBook_Flag_Value",1,CheckIn);
SplashScreenDMN.db.update_CheckTwitterFacebookFour("FaceBook_Flag_Value",1,3);
Log.d("A1","2");
finish();
}
}
public void doNotShare(View button){
finish();
}
public void share(View button){
if (! facebook.isSessionValid()) {
loginAndPostToWall();
}
else
finish();
}
public void loginAndPostToWall(){
facebook.authorize(MyFaceBook.this,PERMISSIONS,Facebook.FORCE_DIALOG_AUTH, new LoginDialogListener());
}
public static void postToWall(String Message_Postbody){
Bundle parameters = new Bundle();
Log.d("Tests", "Testing graph API wall post");
try {
String response = facebook.request("me");
parameters.putString("message",Message_Postbody);
parameters.putString("description","This is 'DATE ME NOW' App's Post");
response = facebook.request("me/feed", parameters,"POST");
Log.d("Tests", "got response: " + response);
if (response == null || response.equals("") ||
response.equals("false")) {
Log.v("Error", "Blank response");
}
} catch(Exception e) {
e.printStackTrace();
}
}
void Login_funcation(){
SharedPreferences.Editor editor = mPrefs.edit();
editor.putString("access_token", facebook.getAccessToken());
editor.putLong("access_expires", facebook.getAccessExpires());
editor.commit();
if(CheckIn == 1 || CheckIn == 2 || CheckIn == 3){
SplashScreenDMN.db.update_CheckTwitterFacebookFour("FaceBook_Flag_Value",1,CheckIn);
SplashScreenDMN.db.update_CheckTwitterFacebookFour("FaceBook_Flag_Value",1,3);
}
if(login_response.equals("Register")) {
PD = ProgressDialog.show(MyFaceBook.this,"","update...");
new Thread(new Runnable() {
public void run() {
Log.d("hello", "heloooooooooo");
String s;
Bundle parameters = new Bundle();
parameters.putString("method", "auth.expireSession");
try
{
s = String.valueOf(facebook.request("me"));
Log.d("facebook response",": "+s);
Server_Response_Fetch.Profile_response(s);
Funcation_CheckInvalue();
handler.sendEmptyMessage(0);
}
catch (IOException e1)
{
s = "IOException";
e1.printStackTrace();
handler.sendEmptyMessage(1);
}
}
}).start();
Log.d("If", "423ffd#@##@@@");
}else if(login_response.equals("Friend_Data")){
Log.d("else If", "423ffd#@##@@@");
String response2 = Friend_Funcation();
finish();
startActivity(new Intent(MyFaceBook.this,com.technosoft.Settings.Facebook_invite.class).putExtra("response", response2));
}else{
finish();
}
}
protected void Funcation_CheckInvalue() {
SplashScreenDMN.db.Retrieve_Editprofile();
String str = SplashScreenDMN.db.Profile_CurrentCity;
if(!str.equals("Do Not Show")){
String []tokens = str.split(",");
for(int j=0; j < tokens.length; j++){
System.out.println("i"+j +":"+ tokens[j]);
}
Server_Response_Fetch.current_city_city = tokens[0];
Server_Response_Fetch.current_city_state = "";
Server_Response_Fetch.current_city_country = tokens[1];
}
String str1 = SplashScreenDMN.db.Profile_HomeTown;
if(!str1.equals("Do Not Show")){
String []tokens = str1.split(",");
for(int j=0; j < tokens.length; j++){
System.out.println("i"+j +":"+ tokens[j]);
}
Server_Response_Fetch.hometown_city = tokens[0];
Server_Response_Fetch.hometown_state = "";
Server_Response_Fetch.hometown_country = tokens[1];
}
String str2 = SplashScreenDMN.db.Profile_Occunpation;
int index2 = 1;
index2 = str2.indexOf("(");
Log.d("indexFacebook","value:-"+index2);
if(!str2.equals("Do Not Show")){
if(index2 > 1){
Server_Response_Fetch.Job_Emp = str2.substring(0, index2-1);
Server_Response_Fetch.Job_title = str2.substring(index2+1, str2.length()-1);
}
else{
Server_Response_Fetch.Job_Emp = str2;
}
}
}
class LoginDialogListener implements DialogListener {
public void onComplete(Bundle values) {
Login_funcation();
}
public void onFacebookError(FacebookError error) {
finish();
}
public void onError(DialogError error) {
finish();
}
public void onCancel() {
finish();
}
}
private Handler handler = new Handler() {
public void handleMessage(android.os.Message msg1) {
PD.dismiss();
if(msg1.what ==0 ){
finish();
startActivity(new Intent(MyFaceBook.this,Looking_For.class));
}
if(msg1.what == 1){
Toast.makeText(getApplicationContext(),"Try Again Server Problem", 2000).show();
finish();
}
}
};
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK) {
if(SplashScreenDMN.db.Check_Edit_profile())
finish();
else{
finish();
startActivity(new Intent(MyFaceBook.this,Login_RegisterScreen.class));
}
return true;
}
return super.onKeyDown(keyCode, event);
}
}Add a code snippet to your website: www.paste.org