Last active
December 29, 2015 01:49
-
-
Save aemxn/7596247 to your computer and use it in GitHub Desktop.
Implementing GetSocialize SDK in Android app - http://aimanbaharum.blogspot.com
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:tools="http://schemas.android.com/tools" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" > | |
<Button | |
android:id="@+id/firstview" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:layout_centerInParent="true" | |
android:text="View 1" /> | |
<Button | |
android:id="@+id/secondview" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:layout_below="@+id/firstview" | |
android:layout_centerInParent="true" | |
android:text="View 2" /> | |
</RelativeLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.aiman.salamdunia; | |
import android.os.Bundle; | |
import android.app.Activity; | |
import android.content.Intent; | |
import android.view.Menu; | |
import android.view.View; | |
import android.view.View.OnClickListener; | |
import android.widget.Button; | |
public class SalamDuniaActivity extends Activity { | |
// Declare variables | |
private Button fvbutton; | |
private Button svbutton; | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
// Get the view from activity_main.xml | |
setContentView(R.layout.activity_salam_dunia); | |
// Locate buttons in activity_main.xml | |
fvbutton = (Button)findViewById(R.id.firstview); | |
svbutton = (Button)findViewById(R.id.secondview); | |
// Listen for first view button click | |
fvbutton.setOnClickListener(new OnClickListener() { | |
public void onClick(View arg0) { | |
// Open FirstView.class | |
Intent myIntent = new Intent(SalamDuniaActivity.this, FirstView.class); | |
SalamDuniaActivity.this.startActivity(myIntent); | |
// TODO Auto-generated method stub | |
} | |
}); | |
// Listen for second view button click | |
svbutton.setOnClickListener(new OnClickListener() { | |
public void onClick(View arg0) { | |
// Open SecondView.class | |
Intent myIntent = new Intent(SalamDuniaActivity.this, SecondView.class); | |
SalamDuniaActivity.this.startActivity(myIntent); | |
// TODO Auto-generated method stub | |
} | |
}); | |
} | |
@Override | |
public boolean onCreateOptionsMenu(Menu menu) { | |
// Inflate the menu; this adds items to the action bar if it is present. | |
getMenuInflater().inflate(R.menu.salam_dunia, menu); | |
return true; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Socialize App Key and Secret | |
socialize.consumer.key=8246c0d9-3931-48cc-8935-85b74584f411 | |
socialize.consumer.secret=cafb2555-667b-42b6-98c7-315974959c4f | |
# Facebook App ID | |
facebook.app.id=1375024316079252 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:tools="http://schemas.android.com/tools" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" > | |
<TextView | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:layout_centerInParent="true" | |
android:text="This is first view" /> | |
</RelativeLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.aiman.salamdunia; | |
import android.app.Activity; | |
import android.graphics.Color; | |
import android.os.Bundle; | |
import com.socialize.ActionBarUtils; | |
import com.socialize.Socialize; | |
import com.socialize.entity.Entity; | |
import com.socialize.ui.actionbar.ActionBarOptions; | |
public class FirstView extends Activity{ | |
@Override | |
public void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
// Call Socialize in onCreate | |
Socialize.onCreate(this, savedInstanceState); | |
// Your entity key. May be passed as a Bundle parameter to your activity | |
String entityKey = "FirstView"; | |
// Create an entity object including a name | |
// The Entity object is Serializable, so you could also store the whole | |
// object in the Intent | |
Entity entity = Entity.newInstance(entityKey, "Socialize"); | |
// Create an options instance to specify your theme | |
ActionBarOptions options = new ActionBarOptions(); | |
// Set the colors for the Action Bar | |
options.setStrokeColor(Color.parseColor("#591100")); // The line between the buttons | |
options.setAccentColor(Color.parseColor("#ffa229")); // The accent line below the buttons | |
options.setFillColor(Color.parseColor("#831400")); // The main color of the buttons | |
options.setBackgroundColor(Color.parseColor("#591100")); // The background color seen on the left | |
options.setHighlightColor(Color.parseColor("#b05e08")); // The thin highlight line above the buttons | |
options.setTextColor(Color.parseColor("#ffba00")); // The text color for all buttons | |
// Wrap your existing view with the action bar. | |
// your_layout refers to the resource ID of your current layout. | |
android.view.View actionBarWrapped = ActionBarUtils.showActionBar(this, | |
R.layout.firstview, entity, options); | |
// Now set the view for your activity to be the wrapped view. | |
setContentView(actionBarWrapped); | |
} | |
@Override | |
protected void onPause() { | |
super.onPause(); | |
// Call Socialize in onPause | |
Socialize.onPause(this); | |
} | |
@Override | |
protected void onResume() { | |
super.onResume(); | |
// Call Socialize in onResume | |
Socialize.onResume(this); | |
} | |
@Override | |
protected void onDestroy() { | |
// Call Socialize in onDestroy before the activity is destroyed | |
Socialize.onDestroy(this); | |
super.onDestroy(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:tools="http://schemas.android.com/tools" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" > | |
<TextView | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:layout_centerInParent="true" | |
android:text="This is second view" /> | |
</RelativeLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.aiman.salamdunia; | |
import android.app.Activity; | |
import android.graphics.Color; | |
import android.os.Bundle; | |
import com.socialize.ActionBarUtils; | |
import com.socialize.Socialize; | |
import com.socialize.entity.Entity; | |
import com.socialize.ui.actionbar.ActionBarOptions; | |
public class SecondView extends Activity{ | |
@Override | |
public void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
// Call Socialize in onCreate | |
Socialize.onCreate(this, savedInstanceState); | |
// Your entity key. May be passed as a Bundle parameter to your activity | |
String entityKey = "SecondView"; | |
// Create an entity object including a name | |
// The Entity object is Serializable, so you could also store the whole | |
// object in the Intent | |
Entity entity = Entity.newInstance(entityKey, "Socialize"); | |
// Create an options instance to specify your theme | |
ActionBarOptions options = new ActionBarOptions(); | |
// Set the colors for the Action Bar | |
options.setStrokeColor(Color.parseColor("#591100")); // The line between the buttons | |
options.setAccentColor(Color.parseColor("#ffa229")); // The accent line below the buttons | |
options.setFillColor(Color.parseColor("#831400")); // The main color of the buttons | |
options.setBackgroundColor(Color.parseColor("#591100")); // The background color seen on the left | |
options.setHighlightColor(Color.parseColor("#b05e08")); // The thin highlight line above the buttons | |
options.setTextColor(Color.parseColor("#ffba00")); // The text color for all buttons | |
// Optionally alter the images | |
options.setLikeIconResourceId(R.drawable.autumn_like); | |
options.setLikeIconActiveResourceId(R.drawable.autumn_like_hi); | |
options.setCommentIconResourceId(R.drawable.autumn_comment); | |
options.setShareIconResourceId(R.drawable.autumn_share); | |
options.setViewIconResourceId(R.drawable.autumn_view); | |
// Wrap your existing view with the action bar. | |
// your_layout refers to the resource ID of your current layout. | |
android.view.View actionBarWrapped = ActionBarUtils.showActionBar(this, | |
R.layout.secondview, entity, options); | |
// Now set the view for your activity to be the wrapped view. | |
setContentView(actionBarWrapped); } | |
@Override | |
protected void onPause() { | |
super.onPause(); | |
// Call Socialize in onPause | |
Socialize.onPause(this); | |
} | |
@Override | |
protected void onResume() { | |
super.onResume(); | |
// Call Socialize in onResume | |
Socialize.onResume(this); | |
} | |
@Override | |
protected void onDestroy() { | |
// Call Socialize in onDestroy before the activity is destroyed | |
Socialize.onDestroy(this); | |
super.onDestroy(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment