我在android 4.4中使用通知监听器服务,我遇到一个错误,导致我的应用程序停止发布通知.
这是相当随机的,但当它发生时,我看到:
12-31 01:40:44.080 21680-21680/? W/ContextImpl? Calling a method in the system process without a qualified user:
android.app.ContextImpl.sendOrderedBroadcast:1192
android.app.ContextImpl.sendOrderedBroadcast:1183
android.content.ContextWrapper.sendOrderedBroadcast:390
com.android.settings.applications.ProcessStatsDetail.checkForceStop:314
com.android.settings.applications.ProcessStatsDetail.onResume:108
Run Code Online (Sandbox Code Playgroud)
在日志中.我甚至可以通过在手机上输入开发者工具的"过程统计数据"部分来重新创建它.一旦我选择了一个使用通知监听器的应用程序,就会发出此警告并取消绑定并销毁该服务,并且当它重新创建时,它并不总是会再次接收事件.
我不确定为什么会发生这种情况,任何人都可以解雇吗?
我一直在尝试这样做.我似乎无法做到正确,我想控制那个父母的每个父母+孩子.ExpandableListView让我很头疼.包评论;
public class CommentsExpandableListAdapter extends BaseExpandableListAdapter {
private Activity context;
private Map<String, List<String>> comments_feed_collection;
private List<String> group_list;
private boolean a_comment = false;
public CommentsExpandableListAdapter(Activity context, List<String> group_list,
Map<String, List<String>> comments_feed_collection) {
this.context = context;
this.comments_feed_collection = comments_feed_collection;
this.group_list = group_list;
}
public Object getChild(int groupPosition, int childPosition) {
return comments_feed_collection.get(group_list.get(groupPosition)).get(childPosition);
}
public long getChildId(int groupPosition, int childPosition) {
return childPosition;
}
public View getChildView(final int groupPosition, final int childPosition,
boolean isLastChild, View convertView, ViewGroup parent) {
final String incoming_text = …Run Code Online (Sandbox Code Playgroud) 我正在尝试让Hadoop在我的Windows机器上运行"本地模式".我一直用它来指导我:http://hadoop.apache.org/docs/r1.2.1/single_node_setup.html
当我运行命令:bin/hadoop时,我收到以下错误消息:"错误:JAVA_HOME设置不正确.请更新C:...\hadoop-2.7.1\conf\hadoop-env.cmd"
在'hadoop-env.cmd'中,我有一行:设置JAVA_HOME =%JAVA_HOME%
请注意,当我在命令行键入echo%JAVA_HOME%时,我得到:C:\ Java\jdk1.0.8_51.
即使我将'hadoop-env.cmd'中的行更改为:set JAVA_HOME = C:\ Java\jdk1.0.8_51我也得到相同的错误...
怎么可能是我的JAVA_HOME设置不正确?
使用firebase_messaging: ^13.0.2我不确定如何强制刷新 FCM 令牌...而不注销用户。我注意到注销+重新登录时它会刷新。
根据谷歌文档,只有 3 种方法可以刷新令牌:
https://firebase.google.com/docs/cloud-messaging/manage-tokens
我作为侦听器在启动时运行的内容:
FirebaseMessaging firebaseMessaging = FirebaseMessaging.instance;
tokenStream = firebaseMessaging.onTokenRefresh.listen((event) {
if (currentUser != null) {
print('token $event');
currentUser!.fcmToken = event;
FireStoreUtils.updateCurrentUserfcmToken(currentUser!);
}
});
Run Code Online (Sandbox Code Playgroud)
如何强制刷新此令牌?这不起作用并产生与运行删除之前相同的标记值...
FirebaseMessaging.instance.deleteToken().then((value) =>
FirebaseMessaging.instance.getToken().then((value) {
currentUser!.fcmToken = value;
FireStoreUtils.updateCurrentUserfcmToken(currentUser!);
}));
Run Code Online (Sandbox Code Playgroud)
如果您想知道为什么我要刷新,请参阅我的其他帖子: IOS 通知停止工作,直到 FCM 令牌刷新
firebase-security firebase-authentication flutter firebase-cloud-messaging
我有一个csv文件,其中42,000行采用以下模式
03055,Milford,NH
03057,Mont Vernon,NH
03060,Nashua,NH
Run Code Online (Sandbox Code Playgroud)
我试图将数据存储在一个HashMap使用zipcode作为键,如
while ((line = stream_in.readLine())!=null) {
LocationBean temp_location_bean = new LocationBean();
String line_trimmed = line.trim();
String[] line_chunked = line_trimmed.split(",",4);
temp_location_bean.setZip_code(line_chunked[0]);
temp_location_bean.setCity(line_chunked[1]);
temp_location_bean.setState(line_chunked[2]);
this.locations_as_beans_list.put(zip_code, temp_location_bean);
}
Run Code Online (Sandbox Code Playgroud)
但是当我去查找时:
for(Map.Entry<String, LocationBean> location_object : this.locations_as_beans_list.entrySet())
{
LocationBean temp_location_bean = location_object.getValue();
if (params[0].matches(temp_location_bean.getZip_code())) {
master_location = temp_location_bean.getCity() + ","
+ temp_location_bean.getState()
+ ", (" + temp_location_bean.getZip_code() +")";
}
}
Run Code Online (Sandbox Code Playgroud)
它需要超过20秒....不应该表现相对较快?我怎样才能提高性能?
tl; dr 如何优化本例中的读取?
编辑:我想更新问题的真正所在。在三星手机上,您有“图库”,在“图库”中,您还可以看到您的谷歌照片备份。这是我想要的照片选择。现在在其他应用程序 (Close5) 上,它们只是显示一条消息,指出 “不支持该照片”。但为什么?为什么我们不能让这个 url (https://lh3.googleusercontent) 工作?
E/BitmapFactory:无法解码流:java.io.FileNotFoundException:/https:/lh3.googleusercontent.com/-Llgk8Mqk-rI/U8LK0SMnpWI/AAAAAAAAFk4/0cktb59DnL8GgblJ-IJIUBDuP9MQXCBPACHM/I/120jpg50:/IJIUBDuP9MQXCBPACHM21/IMG50:/这样的文件或目录)
你们都可以清楚地看到这是一张带有真实网址的真实照片:
https:/lh3.googleusercontent.com/-Llgk8Mqk-rI/U8LK0SMnpWI/AAAAAAAAFk4/0cktb59DnL8GgblJ-IJIUBDuP9MQXCBPACHM/I/IMG_20140711_085012.jpg
Run Code Online (Sandbox Code Playgroud)
一切正常,直到我从照片或谷歌照片图像而不是从图库中选择,我尝试处理异常 ( Sorry, that image isn't supported. Try another gallery!) 但这似乎不完整。我尝试在这里查看其他解决方案,但没有一个适用于谷歌照片。谢谢!
错误是一个空指针:
应用程序 E/BitmapFactory:无法解码流:java.io.FileNotFoundException:/https:/lh3.googleusercontent
@Override
public void onActivityResult(int requestCode, int resultCode,
Intent data) {
if (resultCode != Activity.RESULT_CANCELED) {
if (requestCode == 1) {
try{
String selectedImagePath = getAbsolutePath(data.getData()); ((PostAdParentTabHost)getActivity()).getMap_of_picture_paths().put(1, selectedImagePath);
post_ad_camera_img_1.setImageBitmap(decodeSampledBitmapFromFileToCustomSize(selectedImagePath, 150, 150));
animation_master.fade(post_ad_camera_img_1);
}catch(Exception e){
e.printStackTrace();
((PostAdParentTabHost)getActivity()).getMap_of_picture_paths().remove(requestCode);
Toast.makeText(getActivity(), "Sorry, that image isn't supported. Try another gallery! ", Toast.LENGTH_SHORT).show();
}
//------------------------------------------------------Methods:
public String getAbsolutePath(Uri uri) { …Run Code Online (Sandbox Code Playgroud) 我想遍历的Future<list>,但得到的错误,如果我尝试使用循环或如果我试图将其设置List。
有没有其他方法可以循环遍历列表中的每个元素:
Future<List> getDailyTask(DateTime date) async {
var params = {'date': date.toIso8601String()};
Uri uri = Uri.parse('URL');
final newURI = uri.replace(queryParameters: params);
http.Response response = await http.get(
newURI,
headers: {"Accept": "application/json"},
);
List foo = json.decode(response.body);
return foo;
}
Run Code Online (Sandbox Code Playgroud) 我正在遵循本动画指南:https ://mightytechno.com/flutter-glow-pulse-animation/
当我去使用this它时,它不会让我通过。我无法编译并且 flutter clean 什么也不做。我可以传递什么对象来消除此错误?
void initState() {
getSharedPrefs();
_animationController = AnimationController(vsync: this, duration: Duration(seconds: 2));
_animationController.repeat(reverse: true);
_animation = Tween(begin: 2.0,end: 15.0).animate(_animationController)..addListener((){
setState(() {
});
});
Run Code Online (Sandbox Code Playgroud) 我的Galaxy Note 3上的共享首选项出现了一个奇怪的问题,"saved_name"首选项工作得很好,但是当我尝试保存一个布尔值时它不会保存.实际上日志读取:before:true after:false这绝对没有意义.
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(MainActivity.this); //Get the preferences
final SharedPreferences.Editor editor = prefs.edit();
auto_login_checkbox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
Log.e("login", "before: " + isChecked);
editor.putBoolean("saved_login ", isChecked);
editor.commit();
boolean is_saved = prefs.getBoolean("saved_login", false);
//WHY IS THIS PRINTING FALSE IF THE ABOVE IS TRUE?
Log.e("saved", "after: " + is_saved);
}
});
String name = prefs.getString("saved_name", null); //get a String
if(name != null){
usernameField.setText(name);
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试压缩来自相机或图库的图像,但我尝试在这个问题Flutter & Firebase: Compression before upload image中回答
但是 UI 被冻结了,请问你们有什么解决方案吗?为什么图像插件会遇到这个问题?
更新:
compressImage(imageFile).then((File file) {
imageFile = file;
});
Future<File> compressImage(File imageFile) async {
return compute(decodeImage, imageFile);
}
File decodeImage(File imageFile) {
Im.Image image = Im.decodeImage(imageFile.readAsBytesSync());
Im.Image smallerImage = Im.copyResize(
image, 150); // choose the size here, it will maintain aspect ratio
return new File('123.jpg')
..writeAsBytesSync(Im.encodeJpg(smallerImage, quality: 85));
}
Run Code Online (Sandbox Code Playgroud)
我在此代码中遇到“未处理的异常”
错误:
错误:(22,0)未找到Gradle DSL方法:'multiDexEnabled()'可能的原因:
项目"项目"可能正在使用不包含该方法的Gradle版本.打开Gradle包装文件 构建文件可能缺少Gradle插件.应用Gradle插件
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
}
}
apply plugin: 'android'
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
compile 'com.android.support:support-v13:21.0.3'
compile 'com.android.support:support-annotations:22.2.0'
compile 'com.android.support:multidex:1.0.1'
}
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
// Enabling multidex support.
multiDexEnabled true
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
// Move the tests to tests/java, tests/res, etc...
instrumentTest.setRoot('tests') …Run Code Online (Sandbox Code Playgroud)