Skip to content

Instantly share code, notes, and snippets.

View sanjogshrestha's full-sized avatar

Sanjog Shrestha sanjogshrestha

View GitHub Profile
@sanjogshrestha
sanjogshrestha / Shared Preference Demo - Android
Created June 17, 2014 08:10
Shared Preference Demo - Android
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_shared_preference);
et = (EditText) findViewById(R.id.editText1);
SharedPreferences sp = getSharedPreferences("MY_PREFERENCE", 0);
et.setText(sp.getString("default_value", ""));
/*
* @author Sanjog Shrestha
*/
public class Radio_Button_MainActivity extends Activity implements OnCheckedChangeListener
{
RadioGroup gender_group;
RadioButton male , female;
Button btnsubmit;
@sanjogshrestha
sanjogshrestha / Google Login In Android
Created July 24, 2014 10:13
Google Login In Android
//First you need to activate the Google+ API in Google Cloud Console and create a Project. Submit your SHA1 fingerprint ,package name in the newly formed ClientID . Remember - need to create a public key as well.
import java.io.Console;
import java.io.InputStream;
import org.json.JSONException;
import org.json.JSONObject;
import android.app.Activity;
import android.content.Intent;
import android.content.IntentSender.SendIntentException;
import android.graphics.Bitmap;
@sanjogshrestha
sanjogshrestha / Enable or Disable Button in Android
Created July 26, 2014 16:12
Enable or Disable Button in Android
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
final Button btn1=(Button)findViewById(R.id.button1);
Button btn2=(Button)findViewById(R.id.button2);
Button btn3=(Button)findViewById(R.id.button3);
@sanjogshrestha
sanjogshrestha / Generating SSH key in linux using terminal
Created August 13, 2014 10:19
Generating SSH key in linux using terminal
To check the ssh key already in the system : ls -al ~/.ssh
To generate the new SSH key : ssh-keygen -t rsa -C "your_email@example.com"
Press enter , enter for the all the prompt.
Check connectivity with github : ssh -T git@github.com
@sanjogshrestha
sanjogshrestha / Get Public IP in ubuntu in Terminal
Created August 13, 2014 10:21
Get Public IP in ubuntu in Terminal
$ curl ifconfig.me
(ip address)
@sanjogshrestha
sanjogshrestha / adding maps using fragment
Created September 29, 2014 18:40
adding maps using fragment
LatLng HAMBURG = new LatLng(53.558, 9.927);
LatLng KIEL = new LatLng(53.551, 9.993);
GoogleMap map = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();
if (map !=null){
Log.d("FUApp", "Map isnt null");
Marker hamburg = map.addMarker(new MarkerOptions().position(HAMBURG).title("Hamburg"));
Marker kiel = map.addMarker(new MarkerOptions()
.position(KIEL)
.title("Kiel")
@sanjogshrestha
sanjogshrestha / zooming maps in android
Created September 29, 2014 18:40
zooming maps in android
CameraPosition cameraPosition = new CameraPosition.Builder().target(latlng).zoom(14.0f).build();
CameraUpdate cameraUpdate = CameraUpdateFactory.newCameraPosition(cameraPosition);
map.moveCamera(cameraUpdate);
@sanjogshrestha
sanjogshrestha / hide the title bar for an Activity in XML with existing custom theme
Created September 29, 2014 18:43
hide the title bar for an Activity in XML with existing custom theme
Do this in your onCreate() method.
//Remove title bar
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
//Remove notification bar
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
//set content view AFTER ABOVE sequence (to avoid crash)
this.setContentView(R.layout.your_layout_name_here);
{
"friendslist": [
{
"CurrentLatitude": 31.633437,
"CurrentLongitude": 74.28658,
"FriendId": 190471,
"FriendType": 2,
"FriendsUserName": "ShahFaisal",
"ImgUrl": "https://graph.facebook.com/1813311879/picture?width=200&height=200",
"IsFavorite": false,