小编jul*_*cer的帖子

请求导航器操作的上下文不包含导航器

我正在尝试在onTap中启动一个新屏幕,但是我收到以下错误:

请求导航器操作的上下文不包含导航器.

我用来导航的代码是:

onTap: () { Navigator.of(context).pushNamed('/settings'); },
Run Code Online (Sandbox Code Playgroud)

我在我的应用程序中设置了一条路线,如下所示:

routes: <String, WidgetBuilder>{
    '/settings': (BuildContext context) => new SettingsPage(),
},
Run Code Online (Sandbox Code Playgroud)

我试图使用stocks示例应用程序复制代码.我查看了Navigator和Route文档,但无法弄清楚如何将上下文包含在Navigator中.的context在使用的onTap感从传递到构建方法中的参数引用:

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
Run Code Online (Sandbox Code Playgroud)

SettingsPage是一个类,如下所示:

class SettingsPage extends Navigator {

Widget buildAppBar(BuildContext context) {
  return new AppBar(
    title: const Text('Settings')
  );
}

@override
Widget build(BuildContext context) {
  return new Scaffold(
    appBar: buildAppBar(context),
  );
 }
}
Run Code Online (Sandbox Code Playgroud)

flutter

33
推荐指数
7
解决办法
2万
查看次数

Android facebook-login 库 11.2.0 导致 Android 12 崩溃 - 定位 S+(版本 31 及更高版本)需要 FLAG_IMMUTABLE 或 FLAG_MUTABLE 之一

我使用 Firebase 与 facebook-login 并收到以下错误:

Caused by: java.lang.IllegalArgumentException: my.app.id: Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent.
Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE if some functionality depends on the PendingIntent being mutable, e.g. if it needs to be used with inline replies or bubbles.
    at android.app.PendingIntent.checkFlags(PendingIntent.java:375)
    at android.app.PendingIntent.getBroadcastAsUser(PendingIntent.java:645)
    at android.app.PendingIntent.getBroadcast(PendingIntent.java:632)
    at com.facebook.AccessTokenManager.setTokenExpirationBroadcastAlarm(AccessTokenManager.kt:121)
    at com.facebook.AccessTokenManager.setCurrentAccessToken(AccessTokenManager.kt:94)
    at com.facebook.AccessTokenManager.setCurrentAccessToken(AccessTokenManager.kt:47)
    at com.facebook.AccessToken$Companion.setCurrentAccessToken(AccessToken.kt:428)
    at com.facebook.AccessToken.setCurrentAccessToken(Unknown Source:2)
    at com.facebook.login.LoginManager.finishLogin(LoginManager.java:894)
    at com.facebook.login.LoginManager.onActivityResult(LoginManager.java:247)
    at com.facebook.login.LoginManager$1.onActivityResult(LoginManager.java:186)
Run Code Online (Sandbox Code Playgroud)

我正在使用的 …

android facebook-login firebase

19
推荐指数
2
解决办法
8775
查看次数

不使用Menu按钮启动ICS模拟器

我试图在ICS上的ActionBar中看到溢出菜单,但我没有设备.

我正在使用模拟器并想知道,如何在没有菜单按钮的情况下启动模拟器?我想模拟没有菜单硬件按钮的设备.

我看过:http: //developer.android.com/guide/developing/tools/emulator.html但是我看不到怎么做.

谢谢你的帮助.

android menu android-emulator android-actionbar

17
推荐指数
1
解决办法
3661
查看次数

隐藏ActionBar菜单时,SearchView会聚焦

我有一个带有SearchView的ActionBar.选择菜单按钮时,隐藏/溢出菜单项将显示在下拉列表的右侧.隐藏下拉菜单时,SearchView会聚焦并显示键盘.有没有办法阻止键盘显示(除了触摸SearchView的情况)?

问候,朱利叶斯.

编辑下面添加的代码:以下是我初始化它的方式:

        SearchManager searchManager = (SearchManager) mActivity.getSystemService(Context.SEARCH_SERVICE);
        ((SearchView) mSearchView).setSearchableInfo(searchManager.getSearchableInfo(mActivity.getComponentName()));

        mSearchView.setIconifiedByDefault(mIconified);
        mSearchView.setOnQueryTextListener(this);
        mSearchView.setOnCloseListener(this);
        mSearchView.setFocusable(false);
        mSearchView.setFocusableInTouchMode(false);

        if(null!=mQuery)
            mSearchView.setQuery(mQuery, false);
Run Code Online (Sandbox Code Playgroud)

编辑2:

以下是用户想要开始搜索时的操作:

    @Override
    public boolean onQueryTextSubmit(String query) {
        // Hide keyboard
        InputMethodManager imm = (InputMethodManager) mActivity.getSystemService(
                FragmentActivity.INPUT_METHOD_SERVICE);
        imm.hideSoftInputFromWindow(mSearchView.getWindowToken(), 0);
Run Code Online (Sandbox Code Playgroud)

...

        mSearchView.setFocusable(false);
        mSearchView.setFocusableInTouchMode(false);

        return true;
    }
Run Code Online (Sandbox Code Playgroud)

search android android-actionbar

12
推荐指数
2
解决办法
9032
查看次数

Android Auto - 语音 - 无法执行“在 [y] 上播放 [x]”

我在 [app] 上播放 [song] 命令时遇到问题;特别是 Android Auto 无法识别“应用程序”。

我收到一条语音语音消息:“不知道如何帮助在应用程序上播放歌曲”

所以语音识别工作得很好(就像我说的歌曲和应用程序一样),但是与应用程序的匹配不起作用或者 Auto 并不明显我的应用程序可以处理这个问题。

在模拟器中,搜索从搜索菜单选项开始,所以我假设我的意图过滤器是正确的。

我的清单有以下内容:

    <!-- - - - - - - - - - - - - - - - - - - - - -->
    <!-- Auto -->
    <!-- - - - - - - - - - - - - - - - - - - - - -->
    <meta-data android:name="com.google.android.gms.car.application" android:resource="@xml/automotive_app_desc"/>
    <meta-data android:name="com.google.android.gms.car.notification.SmallIcon" android:resource="@drawable/brand_icon_white" />
    <service android:name=".library.service.auto.MyMediaBrowserService"
        android:exported="true">
        <intent-filter>
            <action android:name="android.media.browse.MediaBrowserService"/>
        </intent-filter>
    </service>
Run Code Online (Sandbox Code Playgroud)

我曾尝试将以下内容放入我的服务声明或YouTube DevByte 中 …

android android-auto

7
推荐指数
2
解决办法
2275
查看次数

Flutter 中常量字符串支持多种语言

我想开始将我所有的常量字符串(如标签等)放在一个可以在稍后阶段进行翻译的地方。

这在 Flutter 中是如何处理的?

flutter

7
推荐指数
2
解决办法
8976
查看次数

崩溃加载WearableActivity

在将AppCompatActivity迁移到WearableActivity时,我收到以下消息的崩溃.

引起:java.lang.IllegalStateException:找不到可穿戴共享库类.请将uses-library android:name ="com.google.android.wearable"android:required ="false"/>添加到应用程序清单

我正在关注此链接以在我的应用程序中启用环境模式: 保持应用程序可见

我的清单和gradle中分别有以下内容:

<uses-library android:name="com.google.android.wearable"
    android:required="false" />
Run Code Online (Sandbox Code Playgroud)

...

minSdkVersion 22
targetSdkVersion 22



compile 'com.google.android.support:wearable:1.2.0'
provided 'com.google.android.wearable:wearable:1.0.0'
compile 'com.google.android.gms:play-services-wearable:7.5.0'
Run Code Online (Sandbox Code Playgroud)

我直接从链接中取了这些(希望我做对了).

我的设备运行以下版本:

  • Android Wear - 1.1.1.1929530

  • Google Play服务 - 7.5.76(2002306-534)

  • Android OS - 5.1.1

我猜测提供android.support.wearable.activity.WearableActivity的库应该捆绑在设备上,但不在那里.

ambient wear-os

3
推荐指数
1
解决办法
2096
查看次数