本文整理汇总了Java中android.content.Intent类的典型用法代码示例。如果您正苦于以下问题:Java Intent类的具体用法?Java Intent怎么用?Java Intent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Intent类属于android.content包,在下文中一共展示了Intent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: startSystemPlayer
import android.content.Intent; //导入依赖的package包/类
private void startSystemPlayer() {
Intent intent = null;
if (mMediaItems != null) {
SerializableList<MediaItem> list = new SerializableList<>();
list.setList(mMediaItems);
intent = SystemVideoPlayerActivity.newIntent(this, list, mCurrentPlayIndex);
intent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
} else if (mUri != null) {
intent = SystemVideoPlayerActivity.newIntent(this, mUri.toString());
intent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
intent.setData(mUri);
} else if (mPlayUrl != null) {
intent = SystemVideoPlayerActivity.newIntent(this, mPlayUrl);
intent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
startActivity(intent);
}
startActivity(intent);
finish();
}
示例2: onActivityResult
import android.content.Intent; //导入依赖的package包/类
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode != Activity.RESULT_OK) {
return;
}
Intent intent = new Intent(RongVoIPIntent.RONG_INTENT_ACTION_VOIP_MULTIAUDIO);
ArrayList<String> userIds = data.getStringArrayListExtra("invited");
userIds.add(RongIMClient.getInstance().getCurrentUserId());
intent.putExtra("conversationType", conversationType.getName().toLowerCase());
intent.putExtra("targetId", targetId);
intent.putExtra("callAction", RongCallAction.ACTION_OUTGOING_CALL.getName());
intent.putStringArrayListExtra("invitedUsers", userIds);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setPackage(context.getPackageName());
context.getApplicationContext().startActivity(intent);
}
示例3: update
import android.content.Intent; //导入依赖的package包/类
private void update(View swipeView, int position,MusicInfo musicInfo,boolean isDelete){
if (isDelete){
final int curId = musicInfo.getId();
final int musicId = MyMusicUtil.getIntShared(Constant.KEY_ID);
//从列表移除
if (label.equals(Constant.LABEL_LAST)){
dbManager.removeMusic(musicInfo.getId(),Constant.ACTIVITY_RECENTPLAY);
}else if (label.equals(Constant.ACTIVITY_MYLOVE)){
dbManager.removeMusic(musicInfo.getId(),Constant.LIST_LASTPLAY);
}
if (curId == musicId) {
//移除的是当前播放的音乐
Intent intent = new Intent(MusicPlayerService.PLAYER_MANAGER_ACTION);
intent.putExtra(Constant.COMMAND, Constant.COMMAND_STOP);
sendBroadcast(intent);
}
recyclerViewAdapter.notifyItemRemoved(position);//推荐用这个
updateView();
}else {
}
//如果删除时,不使用mAdapter.notifyItemRemoved(pos),则删除没有动画效果,
//且如果想让侧滑菜单同时关闭,需要同时调用 ((CstSwipeDelMenu) holder.itemView).quickClose();
((SwipeMenuLayout) swipeView).quickClose();
}
示例4: onClick
import android.content.Intent; //导入依赖的package包/类
@Override
public void onClick(View view) {
switch (view.getId()) {
case R.id.btn_skip:
startActivity(new Intent(this, HomeActivity.class));
finish();
break;
case R.id.editAddMember:
Intent intent = new Intent(this, SelectMembers.class);
startActivityForResult(intent, 1);
break;
case R.id.btn_continue:
addMemberIds();
break;
}
}
示例5: WhatsApp
import android.content.Intent; //导入依赖的package包/类
public void WhatsApp(View view, String TextToUse) {
PackageManager pm=getPackageManager();
try {
Intent waIntent = new Intent(Intent.ACTION_SEND);
waIntent.setType("text/plain");
PackageInfo info=pm.getPackageInfo("com.whatsapp", PackageManager.GET_META_DATA);
//Check if package exists or not. If not then code
//in catch block will be called
waIntent.setPackage("com.whatsapp");
waIntent.putExtra(Intent.EXTRA_TEXT, TextToUse);
startActivity(Intent.createChooser(waIntent, "Share with"));
} catch (PackageManager.NameNotFoundException e) {
Toast.makeText(this, "WhatsApp not Installed", Toast.LENGTH_SHORT).show();
}
}
示例6: shouldOverrideUrlLoading
import android.content.Intent; //导入依赖的package包/类
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url)
{
if (url.startsWith("http:") || url.startsWith("https:"))
{
return false;
}
else if (url.startsWith(WebView.SCHEME_TEL) ||
url.startsWith("sms:") ||
url.startsWith(WebView.SCHEME_MAILTO) ||
url.startsWith(WebView.SCHEME_GEO) ||
url.startsWith("maps:"))
{
try
{
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(url));
startActivity(intent);
}
catch (android.content.ActivityNotFoundException e)
{
}
}
return true;
}
示例7: dispatchRequestPermissionsResultToFragment
import android.content.Intent; //导入依赖的package包/类
private void dispatchRequestPermissionsResultToFragment(int requestCode, Intent data,
Fragment fragment) {
// If the package installer crashed we may have not data - best effort.
String[] permissions = (data != null) ? data.getStringArrayExtra(
PackageManager.EXTRA_REQUEST_PERMISSIONS_NAMES) : new String[0];
final int[] grantResults = (data != null) ? data.getIntArrayExtra(
PackageManager.EXTRA_REQUEST_PERMISSIONS_RESULTS) : new int[0];
fragment.onRequestPermissionsResult(requestCode, permissions, grantResults);
}
示例8: openFile
import android.content.Intent; //导入依赖的package包/类
/**
* 调用系统方式打开文件.
*
* @param context 上下文
* @param file 文件
*/
public static void openFile(Context context, File file) {
try {
// 调用系统程序打开文件.
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setDataAndType(Uri.fromFile(file), MimeTypeMap.getSingleton()
.getMimeTypeFromExtension(
MimeTypeMap
.getFileExtensionFromUrl(
file.getPath())));
context.startActivity(intent);
} catch (Exception ex) {
ex.printStackTrace();
}
}
示例9: promptSpeechInput
import android.content.Intent; //导入依赖的package包/类
/**
* Showing google speech input dialog
* */
private void promptSpeechInput() {
Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,
RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, Locale.getDefault());
intent.putExtra(RecognizerIntent.EXTRA_PROMPT,
getString(R.string.speech_prompt));
try {
startActivityForResult(intent, REQ_CODE_SPEECH_INPUT);
} catch (ActivityNotFoundException a) {
Toast.makeText(getApplicationContext(),
getString(R.string.speech_not_supported),
Toast.LENGTH_SHORT).show();
}
}
示例10: onActivityResult
import android.content.Intent; //导入依赖的package包/类
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if(resultCode == EXTRA_TV_INFO){
// 可能会发生网络切换所以这里要重新设置视频播放地址
String asseturl = mModelVideo.getAsseturl();
if(!TextUtils.isEmpty(asseturl)&&asseturl.contains("0/")) {
int index = asseturl.indexOf("0/");
asseturl = NetWorkUtil.getLocalUrl(LocalVideoProAcitvity.this)+asseturl.substring(index+1,asseturl.length());
mModelVideo.setAsseturl(asseturl);
}
initBindcodeResult();
// if(data!=null) {
// TvBoxInfo boxInfo = (TvBoxInfo) data.getSerializableExtra(EXRA_TV_BOX);
// mBindTvPresenter.handleBindCodeResult(boxInfo);
// }
}else if (resultCode == SCAN_QR) {
if(data!=null) {
String scanResult = data.getStringExtra("scan_result");
mBindTvPresenter.handleQrcodeResult(scanResult);
LogUtils.d("扫描结果:" + scanResult);
}
// showToast(scanResult);
}
}
示例11: allConditionalForwarding
import android.content.Intent; //导入依赖的package包/类
@ReactMethod
public void allConditionalForwarding (String phoneNumber) {
String uri = "tel:*002*" + Uri.encode(phoneNumber+"#");
Intent intent = new Intent(Intent.ACTION_CALL);
intent.setData(Uri.parse(uri));
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
this.reactContext.startActivity(intent);
}
示例12: setData
import android.content.Intent; //导入依赖的package包/类
public void setData(final List<ResultBean.HotInfoBean> data) {
HotGridViewAdapter adapter = new HotGridViewAdapter(mContext, data);
gv_hot.setAdapter(adapter);
//点击事件
gv_hot.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
// Toast.makeText(mContext, "position:" + position, Toast.LENGTH_SHORT).show();
String cover_price = data.get(position).getCover_price();
String name = data.get(position).getName();
String figure = data.get(position).getFigure();
String product_id = data.get(position).getProduct_id();
GoodsBean goodsBean = new GoodsBean(name, cover_price, figure, product_id);
Intent intent = new Intent(mContext, GoodsInfoActivity.class);
intent.putExtra(GOODS_BEAN, goodsBean);
mContext.startActivity(intent);
}
});
}
示例13: callTo
import android.content.Intent; //导入依赖的package包/类
public static void callTo(Context context, String number) {
Uri uri = Uri.parse("tel:" + number);
Intent it = new Intent(Intent.ACTION_DIAL, uri);
context.startActivity(it);
}
示例14: selectImage
import android.content.Intent; //导入依赖的package包/类
private void selectImage() {
final CharSequence[] items = { "Take Photo", "Choose from Gallery","Cancel" };
AlertDialog.Builder builder = new AlertDialog.Builder(GroupSettings.this);
builder.setTitle("Select Photo");
builder.setItems(items, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int item) {
if (items[item].equals("Take Photo")) {
Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
if (takePictureIntent.resolveActivity(getPackageManager()) != null) {
startActivityForResult(takePictureIntent,REQUEST_IMAGE_CAPTURE);
}
} else if (items[item].equals("Choose from Gallery")) {
Intent photoPickerIntent = new Intent(Intent.ACTION_PICK);
photoPickerIntent.setType("image/*");
startActivityForResult(photoPickerIntent, SELECT_PHOTO);
} else if (items[item].equals("Cancel")) {
dialog.dismiss();
}
}
});
builder.show();
}
示例15: create
import android.content.Intent; //导入依赖的package包/类
public static void create(Context context, int id, Intent intent, int smallIcon, String contentTitle, String contentText) {
NotificationManager manager =
(NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
PendingIntent p = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
NotificationCompat.Builder builder = new NotificationCompat.Builder(context)
.setContentIntent(p)
.setContentTitle(contentTitle)
.setContentText(contentText)
.setSmallIcon(smallIcon)
.setAutoCancel(true);
Notification n = builder.build();
manager.notify(id, n);
}