Skip to content

Instantly share code, notes, and snippets.

@LordRaydenMK
LordRaydenMK / Sharing on Android
Created October 30, 2013 12:48
Sharing on Android
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT, "This is my text to send.");
sendIntent.setType("text/plain");
startActivity(Intent.createChooser(sendIntent, getResources().getText(R.string.send_to)));
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Add code to print out the key hash
try {
PackageInfo info = getPackageManager().getPackageInfo(
"com.facebook.samples.hellofacebook",
PackageManager.GET_SIGNATURES);
for (Signature signature : info.signatures) {
@LordRaydenMK
LordRaydenMK / LocationClient
Last active August 29, 2015 14:11
Requesting location updates using the LocationClient from Google Play Services
public class MainActivity extends Activity implements GooglePlayServicesClient.ConnectionCallbacks, GooglePlayServicesClient.OnConnectionFailedListener, LocationListener {
private LocationRequest mLocationRequest;
private LocationClient mLocationClient;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mLocationRequest = LocationRequest.create();
@LordRaydenMK
LordRaydenMK / FusedLocationProviderApi
Last active September 11, 2017 11:46
Using the FusedLocationProviderApi to request location updates
public class MainActivity extends Activity implements LocationListener, GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener {
private LocationRequest mLocationRequest;
private GoogleApiClient mGoogleApiClient;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mLocationRequest = LocationRequest.create();
class Document {
String html;
public Document(String url){
HtmlClient client = new HtmlClient();
html = client.get(url);
}
}
class Document {
String html;
public Document(HtmlClient client, String url) {
html = client.get(url);
}
}
class Document {
String html;
public Document(String html) {
this.html = html;
}
}
//Client 1
Document document = new Document("http://sanastasov.com");
//Client 3
HtmlClient client = new HtmlClient();
String html = client.get("http://sanastasov.com");
Document document = Document(html);
public class MyClass {
@Inject
public MyClass() {
}
}
public class MyAwesomeClass {
private final MyClass myClass;
@Inject
public MyAwesomeClass(MyClass myClass) {
this.myClass = myClass;
}
}