GitHubDroid / geodroid_master_update

GNU General Public License v3.0
1 stars 0 forks source link

Skitch Integration - Sharing #21

Open GitHubDroid opened 10 years ago

GitHubDroid commented 10 years ago

Skitch Integration - Sharing

GitHubDroid commented 10 years ago
    geodroid.app/maps/MapTagsActivity.java

  private double latitude;
  private double longitude;
  private double elevation;
  private String tmppngimagename;
  private String[] tagNamesArray;

          public void onCreate( Bundle icicle ) {

          public void onClick( View v ) {
              intent.putExtra(LibraryConstants.LONGITUDE, longitude);
              intent.putExtra(LibraryConstants.LATITUDE, latitude);
              intent.putExtra(LibraryConstants.ELEVATION, elevation);
                intent.putExtra(LibraryConstants.TMPPNGIMAGENAME, tmppngimagename);
              MapTagsActivity.this.startActivityForResult(intent, SKETCH_RETURN_CODE);
              }
                  });
        --------------------------------------------------------------------
        geodroid.app/maps/MapsActivity.java

        // Add Map SketchNote Work
        ImageButton addMapSketchButton = (ImageButton)       
       findViewById(R.id.addmapsketchbutton);
     addMapSketchButton.setOnClickListener(new Button.OnClickListener(){

            public void onClick(View v) {

            String file_path =      
            Environment.getExternalStorageDirectory().getAbsolutePath() + "/geodroid/";
            File dir = new File(file_path);
            dir.mkdirs();
            File file = new File(dir, "tmp.png");

                            //Share

             Intent shareIntent = new Intent(Intent.ACTION_SEND);
             shareIntent.setType("image/png");                      

             shareIntent.putExtra(Intent.EXTRA_STREAM,Uri.fromFile(file));
             shareIntent.putExtra(Intent.EXTRA_TEXT,"My Image");
             PackageManager pm = getApplicationContext().getPackageManager();
             List<ResolveInfo> activityList = pm.queryIntentActivities(shareIntent, 0);
            for (final ResolveInfo app : activityList) {
                if ((app.activityInfo.name).contains("skitch")) {
                    final ActivityInfo activity = app.activityInfo;
                    final ComponentName name = new       
             ComponentName(activity.applicationInfo.packageName,activity.name);
                    shareIntent.addCategory(Intent.CATEGORY_LAUNCHER);
                    shareIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
                                        | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
                    shareIntent.setComponent(name);
                    startActivity(shareIntent);
                }
            }
                  }

                });