Skip to content

Instantly share code, notes, and snippets.

View mancdevcarl's full-sized avatar

Carl mancdevcarl

  • MancDev
  • Manchester
View GitHub Profile
@mancdevcarl
mancdevcarl / gist:5663633
Created May 28, 2013 15:33
getRuntimeExec()
StringBuffer outputx = null;
try {
Process processx = Runtime.getRuntime().exec("/data/data/com.example.ffmpegencode/ffmpeg -loop_input -i /sdcard/go.jpg -i /sdcard/gohoubi.m4a -shortest -acodec copy /sdcard/goood.mp4");
BufferedReader in = new BufferedReader(new InputStreamReader(processx.getInputStream()));
String line = null;
while ((line = in.readLine()) != null) {
Log.d("", "line");
}
Log.d("", "encoding...");
processx.waitFor();
@mancdevcarl
mancdevcarl / ListViewAdapter.java
Last active December 17, 2015 18:29
Custom Listview Example
public class ListViewAdapter extends BaseAdapter {
private Activity activity;
private ArrayList<VideoObject> data;
private static LayoutInflater inflater = null;
public ImageLoader imageLoader;
Context cx;
public ListViewAdapter(Activity a, ArrayList<VideoObject> videoObjListParam) {
activity = a;
inflater = (LayoutInflater) activity
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
@mancdevcarl
mancdevcarl / gist:5624906
Last active December 17, 2015 14:29
ACTION_SENDTO Intent SMS and Email
try {
if (v == findViewById(R.id.emailbtn)) {
Intent emailIntent = new Intent(Intent.ACTION_SENDTO,Uri.fromParts("mailto", "@", null));
emailIntent.putExtra(Intent.EXTRA_SUBJECT, "TITLE");
emailIntent.putExtra(Intent.EXTRA_TEXT, "TEXT");
startActivity(Intent.createChooser(emailIntent, "Send email..."));
} else if (v == findViewById(R.id.smsbtn)) {
Uri uri = Uri.parse("smsto:");
Intent it = new Intent(Intent.ACTION_SENDTO, uri);
it.putExtra("sms_body", "BODY");
@mancdevcarl
mancdevcarl / gist:5624897
Last active December 17, 2015 14:29
Clipboard programatically
int currentapiVersion = android.os.Build.VERSION.SDK_INT;
if (currentapiVersion >= android.os.Build.VERSION_CODES.HONEYCOMB) {
android.content.ClipboardManager clipboard = (android.content.ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
ClipData clip = ClipData.newPlainText("label", shortUrl);
clipboard.setPrimaryClip(clip);
Toast toast = Toast.makeText(getApplicationContext(),"copied", Toast.LENGTH_LONG);
toast.setGravity(Gravity.CENTER, 0, 0);
toast.show();
} else {
android.text.ClipboardManager clipboard = (android.text.ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
@mancdevcarl
mancdevcarl / BarsFragment.java
Last active December 17, 2015 11:29
This fragment uses 4 vertical seekbars. Each bar is adjustable between 0% and 100%. As a bar is adjusted the other bars adjust in realtime so that the total of all bars always equals 100%
public class BarsFragment extends Fragment {
int[] positionsArray = new int[4];
VerticalSeekBar[] seekBarArray;
LinearLayout ll;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.barsfragment, container, false);
String myTag = getTag();
((MainActivity) getActivity()).setFragmentTag(myTag);
@mancdevcarl
mancdevcarl / ArcProgress.java
Last active March 25, 2018 14:28
Custom Arc seekbar / slider
class ArcProgress extends View {
Context cx;
float width;
float height;
float center_x, center_y;
final RectF oval = new RectF();
final RectF touchArea = new RectF();
float sweep = 0;
float left, right;