本文整理汇总了Java中android.support.v4.content.pm.ShortcutManagerCompat类的典型用法代码示例。如果您正苦于以下问题:Java ShortcutManagerCompat类的具体用法?Java ShortcutManagerCompat怎么用?Java ShortcutManagerCompat使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ShortcutManagerCompat类属于android.support.v4.content.pm包,在下文中一共展示了ShortcutManagerCompat类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: placeShortcut
import android.support.v4.content.pm.ShortcutManagerCompat; //导入依赖的package包/类
public void placeShortcut(Station station) {
// credit: https://medium.com/@BladeCoder/using-support-library-26-0-0-you-can-do-bb75911e01e8
if (ShortcutManagerCompat.isRequestPinShortcutSupported(mContext)) {
ShortcutInfoCompat shortcut = new ShortcutInfoCompat.Builder(mContext, station.getStationName())
.setShortLabel(station.getStationName())
.setLongLabel(station.getStationName())
.setIcon(IconCompat.createWithBitmap(createShortcutIcon(station)))
.setIntent(createShortcutIntent(station))
.build();
ShortcutManagerCompat.requestPinShortcut(mContext, shortcut, null);
Toast.makeText(mContext, mContext.getString(R.string.toastmessage_shortcut_created), Toast.LENGTH_LONG).show();
} else {
Toast.makeText(mContext, mContext.getString(R.string.toastmessage_shortcut_not_created), Toast.LENGTH_LONG).show();
}
}
开发者ID:y20k,项目名称:transistor,代码行数:18,代码来源:ShortcutHelper.java
示例2: installShortCutViaManager
import android.support.v4.content.pm.ShortcutManagerCompat; //导入依赖的package包/类
/**
* Create a shortcut via the AppCompat's shortcut manager.
* <p>
* On Android versions up to 7 shortcut will be created via system broadcast internally.
* <p>
* On Android 8+ the user will have the ability to add the shortcut manually
* or let the system place it automatically.
*/
private static void installShortCutViaManager(Context context, Bitmap bitmap, String url, String title, boolean blockingEnabled) {
if (ShortcutManagerCompat.isRequestPinShortcutSupported(context)) {
final IconCompat icon = (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) ?
IconCompat.createWithAdaptiveBitmap(bitmap) : IconCompat.createWithBitmap(bitmap);
final ShortcutInfoCompat shortcut = new ShortcutInfoCompat.Builder(context, UUID.randomUUID().toString())
.setShortLabel(title)
.setLongLabel(title)
.setIcon(icon)
.setIntent(createShortcutIntent(context, url, blockingEnabled))
.build();
ShortcutManagerCompat.requestPinShortcut(context, shortcut, null);
}
}
开发者ID:mozilla-mobile,项目名称:firefox-tv,代码行数:22,代码来源:HomeScreen.java
示例3: createShortcut
import android.support.v4.content.pm.ShortcutManagerCompat; //导入依赖的package包/类
private void createShortcut(){
Intent intent1 = new Intent(getApplicationContext(), MainActivity.class);
intent1.setAction(Intent.ACTION_VIEW);
intent1.setData(Uri.parse(mSearchView.getText().toString()));
intent1.putExtra("duplicate", false);
ShortcutInfoCompat pinShortcutInfo = new ShortcutInfoCompat.Builder(MainActivity.this, webViewTitle)
.setShortLabel(webViewTitle)
.setIcon(IconCompat.createWithBitmap(favoriteIcon))
.setIntent(intent1)
.build();
ShortcutManagerCompat.requestPinShortcut(MainActivity.this, pinShortcutInfo, null);
}
开发者ID:creativetrendsapps,项目名称:SimplicityBrowser,代码行数:13,代码来源:MainActivity.java
示例4: onCreateHomeScreenShortcut
import android.support.v4.content.pm.ShortcutManagerCompat; //导入依赖的package包/类
@Override
public void onCreateHomeScreenShortcut(AppCompatDialogFragment dialogFragment) {
EditText shortcutNameEditText = dialogFragment.getDialog().findViewById(R.id.shortcut_name_edittext);
Intent intent1 = new Intent(getApplicationContext(), MainActivity.class);
intent1.setAction(Intent.ACTION_VIEW);
intent1.setData(Uri.parse(mSearchView.getText().toString()));
intent1.putExtra("duplicate", false);
ShortcutInfoCompat pinShortcutInfo = new ShortcutInfoCompat.Builder(MainActivity.this, webViewTitle)
.setShortLabel(shortcutNameEditText.getText().toString())
.setIcon(IconCompat.createWithBitmap(StaticUtils.getCircleBitmap(favoriteIcon)))
.setIntent(intent1)
.build();
ShortcutManagerCompat.requestPinShortcut(MainActivity.this, pinShortcutInfo, null);
}
开发者ID:creativetrendsapps,项目名称:SimplicityBrowser,代码行数:15,代码来源:MainActivity.java
示例5: createShortcutWith
import android.support.v4.content.pm.ShortcutManagerCompat; //导入依赖的package包/类
private boolean createShortcutWith(String id, String label, IconCompat icon) {
ShortcutInfoCompat shortcut = new ShortcutInfoCompat.Builder(getContext(), id)
.setIntent(intent)
.setShortLabel(label)
.setIcon(icon)
.build();
return ShortcutManagerCompat.requestPinShortcut(getContext(), shortcut, startHomeScreen());
}
开发者ID:tasomaniac,项目名称:OpenLinkWith,代码行数:9,代码来源:AddToHomeScreenDialogFragment.java
示例6: addShortcut
import android.support.v4.content.pm.ShortcutManagerCompat; //导入依赖的package包/类
private void addShortcut(LayoutElementParcelable path) {
//Adding shortcut for MainActivity
//on Home screen
final Context ctx = getContext();
if (!ShortcutManagerCompat.isRequestPinShortcutSupported(ctx)) {
Toast.makeText(getActivity(),
getString(R.string.addshortcut_not_supported_by_launcher),
Toast.LENGTH_SHORT).show();
return;
}
Intent shortcutIntent = new Intent(ctx, MainActivity.class);
shortcutIntent.putExtra("path", path.desc);
shortcutIntent.setAction(Intent.ACTION_MAIN);
shortcutIntent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
// Using file path as shortcut id.
ShortcutInfoCompat info = new ShortcutInfoCompat.Builder(ctx, path.desc)
.setActivity(getMainActivity().getComponentName())
.setIcon(IconCompat.createWithResource(ctx, R.mipmap.ic_launcher))
.setIntent(shortcutIntent)
.setLongLabel(path.desc)
.setShortLabel(new File(path.desc).getName())
.build();
ShortcutManagerCompat.requestPinShortcut(ctx, info, null);
}
开发者ID:TeamAmaze,项目名称:AmazeFileManager,代码行数:29,代码来源:MainFragment.java
注:本文中的android.support.v4.content.pm.ShortcutManagerCompat类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论