小编Jit*_*P.S的帖子

当应用程序在前台运行时,在警告框中显示推送通知

我正在我的Android应用程序中执行由GCM触发的推送通知.我想显示通知,如果应用程序在警告框中运行,如果应用程序未运行意味着不在前台只显示状态栏通知,您如何确定应用程序是否正在运行并且在前台?是这可以显示这样的通知.现在使用此代码显示状态栏推送通知

  NotificationManager notificationManager = (NotificationManager)
                context.getSystemService(Context.NOTIFICATION_SERVICE);
        Notification notification = new Notification(icon, message, when);

        String title = context.getString(R.string.app_name);

         Intent notificationIntent = new Intent(context, BottomActivity.class);
        // set intent so it does not start a new activity
        notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
        PendingIntent intent = PendingIntent.getActivity(context, 0, notificationIntent, 0);
        notification.setLatestEventInfo(context, title, message, intent);
        notification.flags |= Notification.FLAG_AUTO_CANCEL;

        // Play default notification sound
        notification.defaults |= Notification.DEFAULT_SOUND;

        //notification.sound = Uri.parse("android.resource://" + context.getPackageName() + "your_sound_file_name.mp3");

        // Vibrate if vibrate is enabled
        notification.defaults |= Notification.DEFAULT_VIBRATE;
        notificationManager.notify(0, notification); 
Run Code Online (Sandbox Code Playgroud)

android push-notification google-cloud-messaging

16
推荐指数
1
解决办法
6368
查看次数

登录时的XMPP"stream:error(conflict)"(a)Smack

目前我正在使用xmpp/jabber聊天for android.i刚尝试使用Openfire并尝试连接我的jabber account.connection成功.但我无法发送任何message.it显示一些冲突错误.请检查错误日志给我一个解决方案.

Initializing connection to server eworks port 5222
Connected: true
Creating entry for buddy 'testuser2' with name testuser2
Sending mesage 'Hello mate' to user testuser2@eworks
Buddy:testuser2 - Status:null
stream:error (conflict)
at org.jivesoftware.smack.PacketReader.parsePackets(PacketReader.java:306)
at org.jivesoftware.smack.PacketReader.access$000(PacketReader.java:44)
at org.jivesoftware.smack.PacketReader$1.run(PacketReader.java:76)
Run Code Online (Sandbox Code Playgroud)

xmpp smack asmack

9
推荐指数
1
解决办法
8257
查看次数

错误:在APK Android Studio Error打包期间重复文件

在运行应用程序时,Android Studio中出现意外错误,以下是错误消息

错误:APK /home/jithu/libs/android/android/aa/app/build/outputs/apk/app-debug-unaligned.apk打包过程中的重复文件归档中的路径:META-INF/DEPENDENCIES Origin 1:/ home /jithu/.gradle/caches/modules-2/files-2.1/org.apache.httpcomponents/httpmime/4.3.6/cf8bacbf0d476c7f2221f861269365b66447f7ec/httpmime-4.3.6.jar Origin 2:/home/jithu/.gradle/caches/模块-2 /文件-2.1/org.apache.httpcomponents /的HttpCore/4.4.1/f5aa318bda4c6c8d688c9d00b90681dcd82ce636 /的HttpCore-4.4.1.jar

我也粘贴了我的build.gradle文件

 apply plugin: 'com.android.library'

android {
    compileSdkVersion 21
    buildToolsVersion "21.1.2"

    defaultConfig {
        minSdkVersion 14
        targetSdkVersion 21
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.android.support:appcompat-v7:+'
    compile 'com.google.android.gms:play-services:6.5.87'
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'com.mcxiaoke.volley:library:1.0.15'
    compile 'com.google.code.gson:gson:2.2.4'
    compile "org.apache.httpcomponents:httpcore:4.4.1"
    compile "org.apache.httpcomponents:httpmime:4.3.6"


}
android {
    packagingOptions {
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/LICENSE.txt' …
Run Code Online (Sandbox Code Playgroud)

java android android-studio

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