Skip to content

Instantly share code, notes, and snippets.

@gmavenis
Forked from satoshun/MySocialIntent
Created August 5, 2014 01:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gmavenis/271ac476beb24f6a2bc0 to your computer and use it in GitHub Desktop.
Save gmavenis/271ac476beb24f6a2bc0 to your computer and use it in GitHub Desktop.
package com.example.mysocialintent.libs;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import android.app.Activity;
import android.content.Intent;
public enum MySocialIntent {
INSTANCE;
public Intent getIntent(Activity activity, String content, String key){
return getIntent(activity, content, content, key);
}
public Intent getIntent(Activity activity, String content, String subject, String key){
Intent intent = new Intent(Intent.ACTION_SEND);
intent.putExtra(Intent.EXTRA_TEXT, decoder(content));
intent.putExtra(Intent.EXTRA_SUBJECT, decoder(subject));
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setFlags(0x3000000);
intent.setType("text/plain");
Kinds self = Kinds.other.getType(key);
intent = self.addProperValue(intent);
return intent;
}
private String decoder(String content){
String value = "";
try{
if(content != null)
value = URLDecoder.decode(content, "utf-8");
}catch(UnsupportedEncodingException e){
}
return value;
}
private enum Kinds {
twitter{
String packageName = "com.twitter.android";
String className = "com.twitter.android.PostActivity";
public Intent addProperValue(Intent intent){
intent.setClassName(packageName, className);
return intent;
}
},
gplus{
String packageName = "com.google.android.apps.plus";
String className = "com.google.android.apps.plus.app.ViewStreamActivity";
public Intent addProperValue(Intent intent){
intent.setClassName(packageName, className);
return intent;
}
},
line{
String packageName = "jp.naver.line.android";
String className = "jp.naver.line.android.activity.selectchat.SelectChatActivity";
public Intent addProperValue(Intent intent){
intent.setClassName(packageName, className);
return intent;
}
},
other{
public Intent addProperValue(Intent intent){
return intent;
}
};
public Kinds getType(String key){
for(Kinds instance: Kinds.values()){
if(instance.name().equals(key)){
return instance;
}
}
return other;
}
abstract public Intent addProperValue(Intent intent);
}
}
@akhlaqshah36
Copy link

Hello brother,

Have you manage to get the S/N of LG device?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment