本文整理汇总了Java中android.support.v4.app.FragmentActivity.startActivity方法的典型用法代码示例。如果您正苦于以下问题:Java FragmentActivity.startActivity方法的具体用法?Java FragmentActivity.startActivity怎么用?Java FragmentActivity.startActivity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.v4.app.FragmentActivity
的用法示例。
在下文中一共展示了FragmentActivity.startActivity方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: showRedPacketDetail
import android.support.v4.app.FragmentActivity; //导入方法依赖的package包/类
/**
* 显示红包详情的方法
*
* @param redPacketInfo 红包详情数据
* @param activity FragmentActivity
* @param callBack RPOpenPacketCallback
*/
private void showRedPacketDetail(RedPacketInfo redPacketInfo, FragmentActivity activity, RPOpenPacketCallback callBack) {
if (redPacketInfo.redPacketType.equals(RPConstant.RED_PACKET_TYPE_SINGLE_RANDOM)) {
if (redPacketInfo.messageDirect.equals(RPConstant.MESSAGE_DIRECT_RECEIVE)) {
if (redPacketInfo.status == RPConstant.RED_PACKET_STATUS_RECEIVABLE) {
mRandomDetailCallback = new RandomDetailCallback(redPacketInfo, callBack, activity);
mRandomDetailCallback.receiveRedPacket();
return;
}
}
callBack.hideLoading();
if (mRandomDetailDialogFragment == null) {
mRandomDetailDialogFragment = RandomDetailDialogFragment.newInstance(redPacketInfo);
} else {
//for bug:Fragment already active
if (mRandomDetailDialogFragment.isAdded()) return;
mRandomDetailDialogFragment.setArguments(redPacketInfo);
}
if (mRandomDetailDialogFragment != null && !mRandomDetailDialogFragment.isAdded()) {
showAllowingStateLost(mRandomDetailDialogFragment, activity);
}
} else {
callBack.hideLoading();
Intent intent = new Intent(activity, RPDetailActivity.class);
intent.putExtra(RPConstant.EXTRA_RED_PACKET_INFO, redPacketInfo);
activity.startActivity(intent);
}
}
示例2: handleMenuClick
import android.support.v4.app.FragmentActivity; //导入方法依赖的package包/类
public static boolean handleMenuClick(@NonNull FragmentActivity activity, @NonNull Song song, int menuItemId) {
switch (menuItemId) {
case R.id.action_set_as_ringtone:
MusicUtil.setRingtone(activity, song.id);
return true;
case R.id.action_share:
activity.startActivity(Intent.createChooser(MusicUtil.createShareSongFileIntent(song), null));
return true;
case R.id.action_delete_from_device:
DeleteSongsDialog.create(song).show(activity.getSupportFragmentManager(), "DELETE_SONGS");
return true;
case R.id.action_add_to_playlist:
AddToPlaylistDialog.create(song).show(activity.getSupportFragmentManager(), "ADD_PLAYLIST");
return true;
case R.id.action_play_next:
MusicPlayerRemote.playNext(song);
return true;
case R.id.action_add_to_current_playing:
MusicPlayerRemote.enqueue(song);
return true;
case R.id.action_tag_editor:
Intent tagEditorIntent = new Intent(activity, SongTagEditorActivity.class);
tagEditorIntent.putExtra(AbsTagEditorActivity.EXTRA_ID, song.id);
if (activity instanceof PaletteColorHolder)
tagEditorIntent.putExtra(AbsTagEditorActivity.EXTRA_PALETTE, ((PaletteColorHolder) activity).getPaletteColor());
activity.startActivity(tagEditorIntent);
return true;
case R.id.action_details:
SongDetailDialog.create(song).show(activity.getSupportFragmentManager(), "SONG_DETAILS");
return true;
case R.id.action_go_to_album:
NavigationUtil.goToAlbum(activity, song.albumId);
return true;
case R.id.action_go_to_artist:
NavigationUtil.goToArtist(activity, song.artistId);
return true;
}
return false;
}
示例3: handleMenuClick
import android.support.v4.app.FragmentActivity; //导入方法依赖的package包/类
public static boolean handleMenuClick(@NonNull FragmentActivity activity, @NonNull Song song, int menuItemId) {
switch (menuItemId) {
case R.id.action_set_as_ringtone:
MusicUtil.setRingtone(activity, song.id);
return true;
case R.id.action_share:
activity.startActivity(Intent.createChooser(MusicUtil.createShareSongFileIntent(song, activity), null));
return true;
case R.id.action_delete_from_device:
DeleteSongsDialog.create(song).show(activity.getSupportFragmentManager(), "DELETE_SONGS");
return true;
case R.id.action_add_to_playlist:
AddToPlaylistDialog.create(song).show(activity.getSupportFragmentManager(), "ADD_PLAYLIST");
return true;
case R.id.action_play_next:
MusicPlayerRemote.playNext(song);
return true;
case R.id.action_add_to_current_playing:
MusicPlayerRemote.enqueue(song);
return true;
case R.id.action_tag_editor:
Intent tagEditorIntent = new Intent(activity, SongTagEditorActivity.class);
tagEditorIntent.putExtra(AbsTagEditorActivity.EXTRA_ID, song.id);
if (activity instanceof PaletteColorHolder)
tagEditorIntent.putExtra(AbsTagEditorActivity.EXTRA_PALETTE, ((PaletteColorHolder) activity).getPaletteColor());
activity.startActivity(tagEditorIntent);
return true;
case R.id.action_details:
SongDetailDialog.create(song).show(activity.getSupportFragmentManager(), "SONG_DETAILS");
return true;
case R.id.action_go_to_album:
NavigationUtil.goToAlbum(activity, song.albumId);
return true;
case R.id.action_go_to_artist:
NavigationUtil.goToArtist(activity, song.artistId);
return true;
}
return false;
}
示例4: start
import android.support.v4.app.FragmentActivity; //导入方法依赖的package包/类
public static void start(FragmentActivity fragmentActivity, Class<?> activityClass)
{
fragmentActivity.startActivity(new Intent(fragmentActivity, activityClass), ActivityOptionsCompat.makeSceneTransitionAnimation(fragmentActivity).toBundle());
}
示例5: openFile
import android.support.v4.app.FragmentActivity; //导入方法依赖的package包/类
public static void openFile(FragmentActivity activity, String filepath)
{
File file = new File(filepath);
if (file != null && file.exists() && file.isFile())
{
String fileName = file.toString();
Intent intent = null;
if (isPDFFile(filepath))
{
intent = MIP_OpenFilesUtils.getPdfFileIntent(file);
}
else
{
if (checkEndsWithInStringArray(fileName, fileEndingImage))
{
intent = MIP_OpenFilesUtils.getImageFileIntent(file);
}
else if (checkEndsWithInStringArray(fileName, fileEndingWebText))
{
intent = MIP_OpenFilesUtils.getHtmlFileIntent(file);
}
else if (checkEndsWithInStringArray(fileName, fileEndingPackage))
{
intent = MIP_OpenFilesUtils.getApkFileIntent(file);
}
else if (checkEndsWithInStringArray(fileName, fileEndingAudio))
{
intent = MIP_OpenFilesUtils.getAudioFileIntent(file);
}
else if (checkEndsWithInStringArray(fileName, fileEndingVideo))
{
intent = MIP_OpenFilesUtils.getVideoFileIntent(file);
}
else if (checkEndsWithInStringArray(fileName, fileEndingText))
{
intent = MIP_OpenFilesUtils.getTextFileIntent(file);
}
else if (checkEndsWithInStringArray(fileName, fileEndingPdf))
{
intent = MIP_OpenFilesUtils.getPdfFileIntent(file);
}
else if (checkEndsWithInStringArray(fileName, fileEndingWord))
{
intent = MIP_OpenFilesUtils.getWordFileIntent(file);
}
else if (checkEndsWithInStringArray(fileName, fileEndingExcel))
{
intent = MIP_OpenFilesUtils.getExcelFileIntent(file);
}
else if (checkEndsWithInStringArray(fileName, fileEndingPPT))
{
intent = MIP_OpenFilesUtils.getPPTFileIntent(file);
}
else
{
Toast.makeText(activity, "无法打开,请安装相应的软件!", Toast.LENGTH_SHORT).show();
}
}
try
{
if (intent != null)
{
activity.startActivity(intent);
}
}
catch (Exception e)
{
// TODO: handle exception
Toast.makeText(activity, "无法打开,请安装相应的软件!", Toast.LENGTH_SHORT).show();
}
}
else
{
Toast.makeText(activity, "无法打开该文件!", Toast.LENGTH_LONG).show();
}
}
示例6: goToSettings
import android.support.v4.app.FragmentActivity; //导入方法依赖的package包/类
/**
* Just a helper methods in case the user blocks permission.
* It goes to your application settings page for the user to enable permission again.
*
* @param activity "this"
*/
public static void goToSettings(FragmentActivity activity) {
activity.startActivity(new Intent(
Settings.ACTION_APPLICATION_DETAILS_SETTINGS,
Uri.fromParts("package", activity.getPackageName(), null)));
}