Java Code Examples for android.content.Intent.ACTION_SEND

The following are Jave code examples for showing how to use ACTION_SEND of the android.content.Intent class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: AppChooser   File: SendPresenter.java   View Source Code Vote up 7 votes
SendPresenter(@NonNull SendContract.View view,
              @NonNull BaseSchedulerProvider schedulerProvider,
              @NonNull ActionConfig actionConfig,
              @NonNull ResolveInfosRepository resolveInfosRepository) {
    super(view, schedulerProvider, actionConfig, resolveInfosRepository);

    if (!Intent.ACTION_SEND.equals(actionConfig.actionName)) {
        throw new IllegalArgumentException(actionConfig.actionName +
                " is not " + Intent.ACTION_SEND);
    }
    if (actionConfig.text == null) {
        throw new NullPointerException("actionConfig.text == null");
    }
    if (!MimeType.TEXT_PLAIN.equals(actionConfig.mimeType)) {
        throw new IllegalArgumentException(actionConfig.mimeType + " is not " +
                MimeType.TEXT_PLAIN);
    }
}
 
Example 2
Project: SciChart.Android.Examples   File: ExceptionActivity.java   View Source Code Vote up 7 votes
@Override
public void onClick(View view) {
    switch (view.getId()) {
        case R.id.sendAnEmailButton:
            final Intent intent = new Intent(Intent.ACTION_SEND);
            intent.setType("plain/text");
            intent.putExtra(Intent.EXTRA_EMAIL, new String[] { "" });
            intent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.exception_stack_trace));
            intent.putExtra(Intent.EXTRA_TEXT, Html.fromHtml(message + "<br />" + stackTraceMessage));
            startActivity(intent);
            break;
        case R.id.copyToClipboardButton:
            ClipboardManager clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
            ClipData clip = ClipData.newPlainText("Copied Text", Html.fromHtml(message + "<br />" + stackTraceMessage));
            clipboard.setPrimaryClip(clip);
            Toast.makeText(this, getResources().getString(R.string.exception_clipboard_message), Toast.LENGTH_SHORT).show();
            break;
    }
}
 
Example 3
Project: Mire   File: ActivityContact.java   View Source Code Vote up 7 votes
private void setSendMail(int numbers)
{
	String[] recipient = {"[email protected]"};
	String[] balises =
	{
		getStringSrc(R.string.mail_question), 
		getStringSrc(R.string.mail_suggestion), 
		getStringSrc(R.string.mail_bug)
	};
	String sous_sujet = getStringSrc(R.string.app_name) + ": " + balises[numbers];

	Intent email = new Intent(Intent.ACTION_SEND, Uri.fromParts("mailto", "[email protected]", "null"));
	email.setType("text/plain");
	email.putExtra(Intent.EXTRA_EMAIL, recipient);
	email.putExtra(Intent.EXTRA_SUBJECT, sous_sujet);
	email.putExtra(Intent.EXTRA_TEXT, edit.getText().toString());
	try
	{
		startActivity(Intent.createChooser(email, getStringSrc(R.string.toast_mail_choose_plarforme)));
	} 

	catch (ActivityNotFoundException ex)
	{
		Preferences.longToast(ActivityContact.this, getStringSrc(R.string.toast_mail_send_failed));
	}
}
 
Example 4
Project: BilibiliClient   File: VideoIntroductionFragment.java   View Source Code Vote up 6 votes
@OnClick(R.id.btn_share)
void share(){
    Intent intent = new Intent(Intent.ACTION_SEND);
    intent.setType("text/plain");
    intent.putExtra(Intent.EXTRA_SUBJECT, "分享");
    intent.putExtra(Intent.EXTRA_TEXT, "来自「哔哩哔哩」的分享:" + mVideoDetailsInfo.getDesc());
    startActivity(Intent.createChooser(intent, mVideoDetailsInfo.getTitle()));
}
 
Example 5
Project: Perfect-Day   File: MoreInfoFragment.java   View Source Code Vote up 6 votes
@OnClick(R.id.feedback)
public void onClickFeedBack() {
    Intent intent = new Intent(Intent.ACTION_SEND);
    intent.setType("plain/text");
    intent.putExtra(Intent.EXTRA_EMAIL, new String[]{getString(R.string.my_email)});
    intent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.mail_subject));
    startActivity(Intent.createChooser(intent, ""));
}
 
Example 6
Project: RunHDU   File: ShareUtil.java   View Source Code Vote up 6 votes
public static void shareText(Context context, String content) {
    if (TextUtils.isEmpty(content)) {
        Toast.makeText(context, "文字为空。", Toast.LENGTH_SHORT).show();
    }
    Intent intent = new Intent(Intent.ACTION_SEND);
    intent.putExtra(Intent.EXTRA_TEXT, content);
    intent.setType("text/plain");
    Intent chooser = Intent.createChooser(intent, content);
    context.startActivity(chooser);
}
 
Example 7
Project: RLibrary   File: RUtils.java   View Source Code Vote up 6 votes
public static void shareText(Activity activity, final String title, final String text) {
    Intent intent = new Intent(Intent.ACTION_SEND);
    intent.setType("text/plain");
    intent.putExtra(Intent.EXTRA_SUBJECT, "分享:" + title);
    intent.putExtra(Intent.EXTRA_TEXT, title + " " + text);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    activity.startActivity(Intent.createChooser(intent, "选择分享"));
}
 
Example 8
Project: AndroidBasicLibs   File: FileUtils.java   View Source Code Vote up 6 votes
public static void shareFile(Context context, String title, String filePath) {
    Intent intent = new Intent(Intent.ACTION_SEND);
    Uri uri = Uri.parse("file://" + filePath);
    intent.setType("*/*");
    intent.putExtra(Intent.EXTRA_STREAM, uri);
    context.startActivity(Intent.createChooser(intent, title));
}
 
Example 9
Project: Android_watch_magpie   File: HomeActivity.java   View Source Code Vote up 6 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_home);
    initFragment();
    //display the fragment home witout any value


    //init the sensors
    sensorManager=(SensorManager) getSystemService(SENSOR_SERVICE);
    sensor_pulse=sensorManager.getDefaultSensor(Sensor.TYPE_HEART_RATE);
    sensor_step=sensorManager.getDefaultSensor(Sensor.TYPE_STEP_DETECTOR);
    //register the sensors
    sensorManager.registerListener(this,sensor_step,SensorManager.SENSOR_DELAY_NORMAL);
    //activate a thread for the pulse sensors


        //process information: 30 sec
        //stop time= 30 min
        threadPulse=new SensorsThreadLifecircle(this,sensor_pulse,30000,1000*60*30);
        threadPulse.start();

    displayFragmentHome();

    // Register the local broadcast receiver. make the ling between the Service and the view
    IntentFilter messageFilter = new IntentFilter(Intent.ACTION_SEND);
    MessageReceiver messageReceiver = new MessageReceiver();
    LocalBroadcastManager.getInstance(this).registerReceiver(messageReceiver, messageFilter);

}
 
Example 10
Project: appinventor-extensions   File: Sharing.java   View Source Code Vote up 6 votes
/**
 * Shares a message using Android' built-in sharing.
 */
@SimpleFunction(description = "Shares a message through any capable " +
    "application installed on the phone by displaying a list of the available apps and " +
    "allowing the user to choose one from the list. The selected app will open with the " +
    "message inserted on it.")
public void ShareMessage(String message) {
  Intent shareIntent = new Intent(Intent.ACTION_SEND);
  shareIntent.putExtra(Intent.EXTRA_TEXT, message);
  shareIntent.setType("text/plain");

  // We cannot use Intent.createChooser(shareIntent, "Send using...") because it creates an
  // oversized pop up sharing window.
  this.form.startActivity(shareIntent);
}
 
Example 11
Project: Facebook-Video-Downloader   File: MainActivity.java   View Source Code Vote up 6 votes
public void shareApp()
{
    try {
        Intent i = new Intent(Intent.ACTION_SEND);
        i.setType("text/plain");
        i.putExtra(Intent.EXTRA_SUBJECT, "Facebook Video Downloader");
        String sAux = "\nDo you want to Download Facebook Videos ? .Install this App , Its Amazing :). \n\n";
        sAux = sAux + "https://play.google.com/store/apps/details?id=com.video.fb.facebookvideodownloaderpaid";
        i.putExtra(Intent.EXTRA_TEXT, sAux);
        startActivity(Intent.createChooser(i, "Share this App"));
    } catch(Exception e) {
        //e.toString();
    }
}
 
Example 12
Project: LiteReader   File: ShareManager.java   View Source Code Vote up 6 votes
/**
 * Create an intent with an extra of {@link Intent#EXTRA_TEXT} and an action of {@link Intent#ACTION_SEND}.
 *
 * @param text the text the Intent carries.
 * @return an intent carrying the text with a SEND action.
 */
private Intent createTextIntent(String text) {
    Intent intent = new Intent(Intent.ACTION_SEND);
    intent.setType("text/*");
    intent.putExtra(Intent.EXTRA_TEXT, text);
    return intent;
}
 
Example 13
Project: GitHub   File: IntentUtils.java   View Source Code Vote up 6 votes
/**
 * 获取分享图片的意图
 *
 * @param content 分享文本
 * @param uri     图片uri
 * @return intent
 */
public static Intent getShareImageIntent(final String content, final Uri uri) {
    Intent intent = new Intent(Intent.ACTION_SEND);
    intent.putExtra(Intent.EXTRA_TEXT, content);
    intent.putExtra(Intent.EXTRA_STREAM, uri);
    intent.setType("image/*");
    return intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
}
 
Example 14
Project: airgram   File: ShareBroadcastReceiver.java   View Source Code Vote up 6 votes
@Override
public void onReceive(Context context, Intent intent) {
    String url = intent.getDataString();
    if (url != null) {
        Intent shareIntent = new Intent(Intent.ACTION_SEND);
        shareIntent.setType("text/plain");
        shareIntent.putExtra(Intent.EXTRA_TEXT, url);
        Intent chooserIntent = Intent.createChooser(shareIntent, LocaleController.getString("ShareLink", R.string.ShareLink));
        chooserIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        context.startActivity(chooserIntent);
    }
}
 
Example 15
Project: MaterialAbout   File: IntentUtil.java   View Source Code Vote up 6 votes
public Intent shareThisApp (String subject, String message) {
	Intent intent = new Intent(Intent.ACTION_SEND);
	intent.setType("text/plain");
	intent.putExtra(Intent.EXTRA_SUBJECT, subject);
	intent.putExtra(Intent.EXTRA_TEXT, message);
	return intent;
}
 
Example 16
Project: buildAPKsApps   File: BloodTable.java   View Source Code Vote up 6 votes
@Override
   public boolean onOptionsItemSelected(MenuItem item) {
	switch (item.getItemId()) {
		case android.R.id.home: 
			onBackPressed();
			break;
		case R.id.action_save:
			new SaveImageTask().execute(null, null, null);
			break;
		case R.id.action_share:
			Intent share = new Intent(Intent.ACTION_SEND);
			share.setType("image/png");
	        File folder = new File(Environment.getExternalStorageDirectory() + "/Blood Type");
	        file = new File(folder + "/chart.png");
	        if (!folder.exists()) {
	            folder.mkdir();
	        }
			try {
				if (file.exists()) {
					share.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file));
					startActivityForResult(Intent.createChooser(share, "Share Blood Chart"), 1);
				}
				else {
					new SaveImageTask().execute(null, null, null);
					share.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file));
					startActivityForResult(Intent.createChooser(share, "Share Blood Chart"), 1);
				}
			}
			catch (Exception e) {
			    e.printStackTrace();
			}
	        return true;
		default:
			return super.onOptionsItemSelected(item);
	}
	return true;
}
 
Example 17
Project: Android-Wear-Projects   File: MainActivity.java   View Source Code Vote up 5 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    setAmbientEnabled();
    drawer_itemArrayList = initializeScreenSystem();
    mSelectedScreen = 0;


    // Register the local broadcast receiver
    IntentFilter messageFilter = new IntentFilter(Intent.ACTION_SEND);
    MessageReceiver messageReceiver = new MessageReceiver();
    LocalBroadcastManager.getInstance(this).registerReceiver(messageReceiver, messageFilter);

    // Initialize content to first screen.
    mDrinkFragment = new DrinkWaterFragment();
    FragmentManager fragmentManager = getFragmentManager();
    fragmentManager.beginTransaction().replace(R.id.content_frame, mDrinkFragment).commit();

    // Main Wearable Drawer Layout that holds all the content
    mWearableDrawerLayout = (WearableDrawerLayout) findViewById(R.id.drawer_layout);

    // Top Navigation Drawer
    mWearableNavigationDrawer =
            (WearableNavigationDrawer) findViewById(R.id.top_navigation_drawer);

    mWearableNavigationDrawer.setAdapter(new NavigationAdapter(this));

    // Bottom Action Drawer
    mWearableActionDrawer =
            (WearableActionDrawer) findViewById(R.id.bottom_action_drawer);

    mWearableActionDrawer.setOnMenuItemClickListener(this);

    // Temporarily peeks the navigation and action drawers to ensure the user is aware of them.
    ViewTreeObserver observer = mWearableDrawerLayout.getViewTreeObserver();
    observer.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
        @Override
        public void onGlobalLayout() {
            mWearableDrawerLayout.getViewTreeObserver().removeOnGlobalLayoutListener(this);
            mWearableDrawerLayout.peekDrawer(Gravity.TOP);
            mWearableDrawerLayout.peekDrawer(Gravity.BOTTOM);
        }
    });
}
 
Example 18
Project: gdgApp   File: MainActivity.java   View Source Code Vote up 5 votes
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
    // Handle navigation view item clicks here.
    int id = item.getItemId();

    if (id == R.id.nav_home) {
        getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container_home,new HomeSection()).commit();
        if(getSupportActionBar() !=null)
            getSupportActionBar().setTitle(R.string.google_dev);

    } else if (id == R.id.nav_event) {
        getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container_home,new EventLists()).commit();
        if(getSupportActionBar() !=null)
            getSupportActionBar().setTitle(R.string.events);

    } else if (id == R.id.nav_notify) {
        getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container_home,new Notify()).commit();
        if(getSupportActionBar() !=null)
            getSupportActionBar().setTitle(R.string.notify);

    } else if (id == R.id.nav_add_event) {
        //startActivity(new Intent(getApplicationContext(),EventDetails.class));
        if(getSupportActionBar() !=null)
            getSupportActionBar().setTitle(R.string.add_event);

    } else if (id == R.id.nav_share) {
        Intent intent = new Intent(Intent.ACTION_SEND);
        intent.setType("text/plain");
        intent.putExtra(Intent.EXTRA_TEXT,getString(R.string.share_text));
        startActivity(Intent.createChooser(intent,getString(R.string.send_using)));

    } else if (id == R.id.nav_about_us) {
        startActivity(new Intent(this,AboutUs.class));
    }
 else if (id == R.id.nav_signOut) {
   FirebaseAuth.getInstance().signOut();
   startActivity(new Intent(this,LoginActivity.class));
   finish();
}

    DrawerLayout drawer = findViewById(R.id.drawer_layout);
    drawer.closeDrawer(GravityCompat.START);
    return true;
}
 
Example 19
Project: Show_Chat   File: BaseActivity.java   View Source Code Vote up 5 votes
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
    switch (item.getItemId()) {
        case R.id.nav_menu_home:
            startActivity(new Intent(BaseActivity.this, HomeActivity.class));
            break;
        case R.id.nav_menu_movies:
            createBackStack(new Intent(BaseActivity.this, MoviesActivity.class));
            break;
        case R.id.nav_menu_tv:
            createBackStack(new Intent(BaseActivity.this, TvActivity.class));
            break;
        case R.id.nav_menu_discover:
            createBackStack(new Intent(BaseActivity.this, DiscoverActivity.class));
            break;
        case R.id.nav_menu_feedback:
            Intent sendMessage = new Intent(Intent.ACTION_SEND);
            sendMessage.setType("message/rfc822");
            sendMessage.putExtra(Intent.EXTRA_EMAIL, new String[]{
                    getResources().getString(R.string.feedback_email)});
            try {
                startActivity(Intent.createChooser(sendMessage, "Send feedback"));
            } catch (android.content.ActivityNotFoundException e) {
                Toast.makeText(BaseActivity.this, "Communication app not found",
                        Toast.LENGTH_SHORT).show();
            }
            break;
        case R.id.nav_menu_settings:
            createBackStack(new Intent(BaseActivity.this, SettingsActivity.class));
            break;

        case R.id.nav_menu_talk:
            startActivity(new Intent(BaseActivity.this, MainActivity.class));
            break;
        case R.id.nav_menu_donation:
            DonationDialog dialog = DonationDialog.newInstance();
            dialog.show(getFragmentManager(), "bitcoinDonationDialog");
            break;
    }

    mDrawerLayout.closeDrawer(GravityCompat.START);
    return true;
}
 
Example 20
Project: GitHub   File: ShareUtil.java   View Source Code Vote up 5 votes
public static void shareText(Context context,String text,String title){
    Intent intent = new Intent(Intent.ACTION_SEND);
    intent.setType("text/plain");
    intent.putExtra(Intent.EXTRA_TEXT,text);
    context.startActivity(Intent.createChooser(intent,title));
}