即使服务器收到成功消息,也无法在我的设备中接收 GCM 消息

2024-01-10

我从 gcm 收到了作为对 Web 服务器(本地主机)的响应的成功消息。但设备未收到该消息。请帮忙。下面是我使用的代码。

主要活动

package vitpat.placement;

import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;

import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;

import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.GooglePlayServicesUtil;
import com.google.android.gms.gcm.GoogleCloudMessaging;

import android.os.AsyncTask;
import android.os.Bundle;
import android.os.StrictMode;
import android.app.Activity;    
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager.NameNotFoundException;
import android.util.Log;
import android.view.Menu;
import android.view.View;
import android.widget.ProgressBar;
import android.widget.TextView;


public class MainActivity extends Activity {

    private final static int PLAY_SERVICES_RESOLUTION_REQUEST = 9000;
    public static final String EXTRA_MESSAGE = "message";
    public static final String PROPERTY_REG_ID = "registration_id";
    private static final String PROPERTY_APP_VERSION = "appVersion";

    TextView textUnderProgressBar;
    String SENDER_ID = "794097343372";
    final String TAG = "GCMDemo";
    TextView mDisplay;
    GoogleCloudMessaging gcm;
    AtomicInteger msgId = new AtomicInteger();
    SharedPreferences prefs;
    Context context;
    String regid;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        if (android.os.Build.VERSION.SDK_INT > 9) {
            StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
            StrictMode.setThreadPolicy(policy);
        }

        textUnderProgressBar = (TextView) findViewById(R.id.textView1);
        context = getApplicationContext();

        //shared preference to check if the application is being run for the first time and the user is yet to be verified
        SharedPreferences prefToVerifyUser = getApplicationContext().getSharedPreferences("MyPref", 0); // 0 - for private mode
        Boolean isUserVerified = prefToVerifyUser.getBoolean("UserVerified", false);
        Log.e("main activity", isUserVerified.toString());
        if(isUserVerified == false) {
            Intent intent = new Intent(this,Check_User_Authentication.class);
            startActivityForResult(intent, 0);
        }
        else {
        //end of shared preference check

        ProgressBar progress = (ProgressBar) findViewById(R.id.progressBar1);
        progress.setIndeterminate(true);
        progress.setVisibility(View.VISIBLE);

        // Check device for Play Services APK.
        if(CheckForPlayStoreApp()) {
            //code
            textUnderProgressBar.setText("Contacting Server..");
            gcm = GoogleCloudMessaging.getInstance(this);
            regid = getRegistrationId(context);
            if (regid.isEmpty()) {
                registerInBackground();
            }
            else {
                textUnderProgressBar.setText(regid.toString());
                /*GcmBroadcastReceiver gcr;
                GcmBroadcastReceiver.startWakefulService(getApplicationContext(), getIntent());*/

            }
        } else {
            Log.i(TAG, "No valid Google Play Services APK found.");
        }
        }
    }

    /**
     * Check the device to make sure it has the Google Play Services APK. If
     * it doesn't, display a dialog that allows users to download the APK from
     * the Google Play Store or enable it in the device's system settings.
     */
    private boolean CheckForPlayStoreApp() {
        int resultCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);
        if (resultCode != ConnectionResult.SUCCESS) {
            if (GooglePlayServicesUtil.isUserRecoverableError(resultCode)) {
                GooglePlayServicesUtil.getErrorDialog(resultCode, this,
                        PLAY_SERVICES_RESOLUTION_REQUEST).show();
            } else {
                Log.i("CheckForPlayStoreApp", "This device is not supported.");
                finish();
            }
            return true;
        }
        return true;
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

    // You need to do the Play Services APK check here too.
    @Override
    protected void onResume() {
        super.onResume();
        CheckForPlayStoreApp();
    }

    /**
     * Gets the current registration ID for application on GCM service.
     * <p>
     * If result is empty, the app needs to register.
     *
     * @return registration ID, or empty string if there is no existing
     *         registration ID.
     */
    private String getRegistrationId(Context context) {
        final SharedPreferences prefs = getGCMPreferences(context);
        String registrationId = prefs.getString(PROPERTY_REG_ID, "");
        if (registrationId.isEmpty()) {
            Log.i(TAG, "Registration not found.");
            return "";
        }
        // Check if app was updated; if so, it must clear the registration ID
        // since the existing regID is not guaranteed to work with the new
        // app version.
        int registeredVersion = prefs.getInt(PROPERTY_APP_VERSION, Integer.MIN_VALUE);
        int currentVersion = getAppVersion(context);
        if (registeredVersion != currentVersion) {
            Log.i(TAG, "App version changed.");
            return "";
        }
        return registrationId;
    }
    /**
     * @return Application's {@code SharedPreferences}.
     */
    private SharedPreferences getGCMPreferences(Context context) {
        // This sample app persists the registration ID in shared preferences, but
        // how you store the regID in your app is up to you.
        return getSharedPreferences(MainActivity.class.getSimpleName(),
                Context.MODE_PRIVATE);
    }

    /**
     * @return Application's version code from the {@code PackageManager}.
     */
    private static int getAppVersion(Context context) {
        try {
            PackageInfo packageInfo = context.getPackageManager()
                    .getPackageInfo(context.getPackageName(), 0);
            return packageInfo.versionCode;
        } catch (NameNotFoundException e) {
            // should never happen
            throw new RuntimeException("Could not get package name: " + e);
        }
    }

    /**
     * Registers the application with GCM servers asynchronously.
     * <p>
     * Stores the registration ID and app versionCode in the application's
     * shared preferences.
     */
    private void registerInBackground() {
        Log.e("inside register", "sample0");
        new AsyncTask<Void, Void, Void>() {


            @Override
            protected Void doInBackground(Void... params) {

                Log.e("inside register", "sample1");
                  String msg = "";
                    try {
                        if (gcm == null) {
                            gcm = GoogleCloudMessaging.getInstance(context);
                        }
                        regid = gcm.register(SENDER_ID);
                        Log.e("inside register", regid);
                        msg = "Device registered, registration ID=" + regid;

                        // You should send the registration ID to your server over HTTP,
                        // so it can use GCM/HTTP or CCS to send messages to your app.
                        // The request to your server should be authenticated if your app
                        // is using accounts.
                        sendRegistrationIdToBackend();

                        // For this demo: we don't need to send it because the device
                        // will send upstream messages to a server that echo back the
                        // message using the 'from' address in the message.

                        // Persist the regID - no need to register again.
                        storeRegistrationId(context, regid);
                    } catch (IOException ex) {
                        msg = "Error :" + ex.getMessage();
                        // If there is an error, don't just keep trying to register.
                        // Require the user to click a button again, or perform
                        // exponential back-off.
                    }

                return null;
            }


        }.execute(null, null, null);

    }

    /**
     * Sends the registration ID to your server over HTTP, so it can use GCM/HTTP
     * or CCS to send messages to your app. Not needed for this demo since the
     * device sends upstream messages to a server that echoes back the message
     * using the 'from' address in the message.
     */
        private void sendRegistrationIdToBackend() {
        // Your implementation here.
        String url = "http://192.168.43.112/dist/addregistrationid.php";

        SharedPreferences prefUserDetails = getApplicationContext().getSharedPreferences("UserDetails", 0);
        String registerNumber = prefUserDetails.getString("registerNumber", null);


        List<NameValuePair> params = new ArrayList<NameValuePair>();
        params.add(new BasicNameValuePair("regid", regid));
        params.add(new BasicNameValuePair("regno", registerNumber));
        DefaultHttpClient httpClient = new DefaultHttpClient();
        HttpPost httpPost = new HttpPost(url);
        try {
            httpPost.setEntity(new UrlEncodedFormEntity(params));
        } 
        catch (UnsupportedEncodingException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        }
        try {
            HttpResponse httpResponse = httpClient.execute(httpPost);
        } catch (ClientProtocolException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }         
    }

    /**
     * Stores the registration ID and app versionCode in the application's
     * {@code SharedPreferences}.
     *
     * @param context application's context.
     * @param regId registration ID
     */
    private void storeRegistrationId(Context context, String regId) {
        final SharedPreferences prefs = getGCMPreferences(context);
        int appVersion = getAppVersion(context);
        Log.i(TAG, "Saving regId on app version " + appVersion);
        SharedPreferences.Editor editor = prefs.edit();
        editor.putString(PROPERTY_REG_ID, regId);
        editor.putInt(PROPERTY_APP_VERSION, appVersion);
        editor.commit();
    }


}

Gcm广播接收器

public class GcmBroadcastReceiver extends WakefulBroadcastReceiver {

    @Override
    public void onReceive(Context context, Intent intent) {
        // TODO Auto-generated method stub
         ComponentName comp = new ComponentName(context.getPackageName(),GcmIntentService.class.getName());
            // Start the service, keeping the device awake while it is launching.
         startWakefulService(context, (intent.setComponent(comp)));
         setResultCode(Activity.RESULT_OK);


    }

}



Gcm意图服务

public class GcmIntentService extends IntentService {

    Context context;
    public static final int NOTIFICATION_ID = 1;
    private NotificationManager mNotificationManager;
    NotificationCompat.Builder builder;
    public static final String TAG = "GCM Demo";

    public GcmIntentService() {
        super("GcmIntentService");
        // TODO Auto-generated constructor stub
    }

    @Override
    protected void onHandleIntent(Intent intent) {
        // TODO Auto-generated method stub
        Bundle extras = intent.getExtras();
        String msg = intent.getStringExtra("message");
        GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this);
        String messageType = gcm.getMessageType(intent);

         if (!extras.isEmpty()) {

             if (GoogleCloudMessaging.
                        MESSAGE_TYPE_SEND_ERROR.equals(messageType)) {
                    sendNotification("Send error: " + extras.toString());
                } else if (GoogleCloudMessaging.
                        MESSAGE_TYPE_DELETED.equals(messageType)) {
                    sendNotification("Deleted messages on server: " +
                            extras.toString());
                // If it's a regular GCM message, do some work.
                } else if (GoogleCloudMessaging.
                        MESSAGE_TYPE_MESSAGE.equals(messageType)) {
                    // This loop represents the service doing some work.
                    for (int i=0; i<5; i++) {
                        Log.i(TAG, "Working... " + (i+1)
                                + "/5 @ " + SystemClock.elapsedRealtime());
                        try {
                            Thread.sleep(500);
                        } catch (InterruptedException e) {
                        }
                    }
                    Log.i(TAG, "Completed work @ " + SystemClock.elapsedRealtime());
                    // Post notification of received message.
                    //sendNotification("Received: " + extras.toString());
                    sendNotification(msg);
                    Log.i(TAG, "Received: " + extras.toString());
                }
            }
         GcmBroadcastReceiver.completeWakefulIntent(intent);
    }
    private void sendNotification(String msg) {
        mNotificationManager = (NotificationManager)
                this.getSystemService(Context.NOTIFICATION_SERVICE);

        Intent myintent = new Intent(this, ReceiveActivity.class);
        myintent.putExtra("message", msg);
        PendingIntent contentIntent = PendingIntent.getActivity(this, 0,
                myintent, PendingIntent.FLAG_UPDATE_CURRENT);

        NotificationCompat.Builder mBuilder =
                new NotificationCompat.Builder(this)
       // .setSmallIcon(R.drawable.ic_stat_gcm)
        .setContentTitle("GCM Notification")
        .setStyle(new NotificationCompat.BigTextStyle()
        .bigText(msg))
        .setContentText(msg);

        mBuilder.setContentIntent(contentIntent);
        mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build());


    }
}

Manifest

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="vitpat.placement"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="11"
        android:targetSdkVersion="19" />
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.GET_ACCOUNTS" />
    <uses-permission android:name="android.permission.WAKE_LOCK" />
    <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
    <permission android:name="vitpat.placement.permission.C2D_MESSAGE"
        android:protectionLevel="signature" />
    <uses-permission android:name="vitpat.placement.permission.C2D_MESSAGE" />

    <application

        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="vitpat.placement.MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity 
            android:name="vitpat.placement.Check_User_Authentication"
            android:theme="@android:style/Theme.Dialog">
        </activity>

        <receiver
            android:name=".GcmBroadcastReceiver"
            android:permission="com.google.android.c2dm.permission.SEND" >
            <intent-filter>
                <action android:name="com.google.android.c2dm.intent.RECEIVE" />
                <category android:name="vitpat.placement" />
            </intent-filter>
        </receiver>
        <service android:name=".GcmIntentService" />
        <meta-data android:name="com.google.android.gms.version"
           android:value="@integer/google_play_services_version" />
        <activity android:name="vitpat.placement.ReceiveActivity"></activity>
    </application>


</manifest>

我自己找到了解决方案。我当时用的是“安卓 API 密钥“将消息从我的网络服务器(php)发送到 gcm 服务器,这就是问题所在。使用”浏览器API“关键解决了问题.. 创建一个新的 ”浏览器 API 密钥" 从 google 控制台并在 php 代码中使用它从 Web 服务器向 gcm 发送消息。

如果您想从 Android 设备向 gcm 发送消息,请尝试使用 android key。 确保您在 google console 下从同一项目创建所有这些密钥。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

即使服务器收到成功消息,也无法在我的设备中接收 GCM 消息 的相关文章

  • FCM 服务不可用 nack

    我有一个 python3 程序 可以成功连接到 FCM XMPP 测试服务器 但是 发送 JSON 后 它返回给我一个SERVICE UNAVAILABLE每次nack消息 上周的同一段代码运行得非常好 The 文档 https fireb
  • 应用程序未运行时小米未收到通知

    我正在开发一个使用 Google 推送通知的应用程序 该应用程序在小米手机中运行时会收到通知 否则 当它被杀死时 它不会收到通知 如果我们想在应用程序被终止时收到通知 那么我们需要从小米的安全应用程序手动允许自动重启应用程序 我想要任何技巧
  • java.lang.NoClassDefFoundError: com.google.android.gcm.GCMRegistrar

    我的应用程序中有 GCM 更新 Android SDK 工具后 我的应用程序崩溃了 我会收到这个错误 E AndroidRuntime 24175 java lang NoClassDefFoundError com google andr
  • 基于 XMPP 协议的 Google Cloud Messaging(使用 PHP 和 XMPPHP 的服务器)。它是如何工作的?

    也许你已经听说过它 它是在一个月前的 Google IO 上宣布的 Google Cloud Messaging 仅位于下游 服务器 gt 电话 但现在通过增强的 CCS 云连接服务器 您可以通过持久 TCP 连接向上游发送消息 这要归功于
  • 如何在 FCM 通知中创建主题

    我正在尝试 Firebase Notification API 当我从控制台向应用程序发送下游消息时 该服务工作得非常完美 但是如何向主题注册用户发送消息 我在android端做了 FirebaseMessaging getInstance
  • Android 推送通知状态检查

    用户可以在更高版本的 Android 中为应用程序禁用推送通知 应用程序有什么方法可以知道用户在设置中禁用了推送通知 看这里 http developer android com google gcm adv html unreg http
  • 接收 gcm 推送通知时刷新活动

    Update GCM https developers google com cloud messaging 已弃用 请使用FCM https firebase google com docs cloud messaging How to
  • GCM 返回空消息类型

    我创建了一个使用 GoogleCloudMessaging 的应用程序 应用程序可以注册到 gcm 并将其注册 ID 存储到我服务器上的数据库中 我正在使用 php 来发送推送通知 但是当 google 将其发送到我的设备时 意图服务发现其
  • 如何使用 Firebase Cloud Messaging 将推送通知发送到多个设备

    我正在寻找一种将推送消息从我的 Express JS 服务器传递到我的离子应用程序的方法 我发现GCM 使用 GCM 我可以传递传递令牌列表的消息 如下所示 sender send message registrationTokens de
  • GCM:java.lang.NoClassDefFoundError:com/google/android/gcm/server/Sender

    我一直在尝试让 Google Cloud Messaging 在 Eclipse 中工作 我能够编译他们的演示网页上给出的示例并运行它 没有任何错误 但是 当我尝试使用 jersey 创建自己的示例时 当以下代码尝试创建发件人时 我收到运行
  • 一台服务器向 Android 和 iOS 设备发送推送通知

    我们的组织有一个 Android 应用程序和一个 iOS 应用程序 我们希望开始向这些应用程序推送通知 安卓有GCM 苹果有APNS 但我们想要创建一个可以在 Android 和 iOS 上运行的 API 设置服务器的最简单方法是什么 以便
  • 构建错误 Ionic Android:构建失败并出现异常

    我尝试为 Android 构建一个离子应用程序 但出现此错误 What went wrong A problem occurred configuring root project android gt Could not resolve
  • 如何使用 GCM 在 php 中向数百万 Android 设备发送通知

    我是一名新的 Android 应用程序开发人员 我正在使用 GCM 将 PHP 代码的通知发送到 Android 设备 我制作了所有设备 ID 的数组并发送 但问题是当我发送超过一千个设备时 我发现内部服务器错误 我的代码如下 functi
  • 使用 BroadcastReceiver 进行推送通知时不会被调用

    我正在尝试在插件中使用 Android 的 GCM 推送通知 我正在从 Google 服务器获取有效的注册 ID 但是当我从服务器发送任何数据时 BroadcastReceiver根本没有被叫到 我认为问题在于清单中的权限 这是我正在使用的
  • 从 GCM 2.0 迁移到 GCM 3.0 InstanceID API

    目前我已经在 Play 商店上发布了我的应用程序 并且在该项目中我正在使用 compile com google android gms play services 7 0 0 Google Play 服务库版本7 0在我的项目中使用 Go
  • GCM 条款和条件

    有谁知道在哪里可以找到有关哪些内容可以通过 GCM 通知发送以及哪些内容不可以发送的条款和条件 我似乎在任何地方都找不到任何文档 当您注册开设 Google API 帐户时 您会得到这些条款和条件 https developers goog
  • GCM 推送通知延迟

    我们有一个应用程序 Ruby on Rails 向 Android 应用程序发送推送通知 我们面临着 GCM 的问题 其中一些通知要么被延迟 要么从未收到 考虑到这些通知是发送给员工而不是最终用户 我的问题是 在没有任何延迟或丢失的情况下发
  • 设备收到 GCM Android 通知但未显示

    尽管通知已在应用程序本身中注册 但我的 Ionic Android 应用程序的 GCM Cloud 消息通知未出现在我的设备的主屏幕中 我正在使用 npm 模块node gcm https www npmjs com package nod
  • 如果应用程序被杀死,小米手机中不会收到 GCM 推送通知

    我将 GCM 集成到我的项目中以接收来自服务器的推送通知 我能够在所有设备 Nexus 三星等 中成功接收推送通知 但是 我在小米手机上收不到通知 当应用程序正在运行或在后台时 我会收到通知 但是如果我终止该应用程序 通过将应用程序从最近的
  • FCM HTTP V1 API 对于未注册的令牌返回 404

    当设备未注册 应用程序已卸载 时 FCM HTTP v1 API 应该返回错误代码 UNREGISTERED 然而 API 返回 404 未找到请求的实体 有人经历过这个吗 这是预期的吗 文档中没有任何地方提到这一点 当收到消息 未找到请求

随机推荐

  • 执行 sidekiq 登录 heroku

    我想在我的 heroku 环境中执行 sidekiq 日志文件 但我在文档中找不到任何内容 谷歌也没有在这里帮助我 我确信它一定是这样的exec sidekiq L log sidekiq log但该命令在 Heroku 上失败 如何在 h
  • 通过触摸或点击在 Android Google 地图上添加标记

    我想在 Android 上使用 Google 地图开发地图应用程序 现在 我想通过触摸或点击地图在地图上添加标记 如何应用触摸事件将标记放在地图上 尝试使用新的谷歌地图 API v2 https developers google com
  • 将非连续列数据合并为单列

    我想将值从列 B C D 复制到列 J 同时保持值的行位置 我想将值从 E F G 列复制到 K 列 同时保持行位置 Desired results in Cols J K The colors are only to clarify my
  • AngularJS - 依赖下拉列表:在模型中存储一个值,使用其他值作为下一个下拉列表的源

    我有两个依赖的下拉菜单 一个显示国家 另一个显示国家 我希望第一个只保存国家 地区 ID 但使用整个对象作为源 对于第二个下拉列表 这是我到目前为止所拥有的 同一屏幕中可能有许多这样的下拉菜单 因此这可能会使事情变得复杂 因为我需要复制临时
  • 如何以编程方式从 win7 中的“屏幕分辨率”对话框获取显示器编号?

    当您按 屏幕分辨率 对话框中的 识别 按钮时 Windows 会在每个显示器上显示大的白色显示器编号 在 Windows XP 中 使用 EnumDisplayDevices 很容易以编程方式与显示器坐标一起找到它们 但在 Windows
  • 通过php提取excel中动态变化的数据

    我有一个打开的 Excel 工作表 另一个程序通过 DDE 不断更新该工作表 我希望有一个 php 脚本来访问此 Excel 工作表中的一些数据 我尝试过使用 PHPExcel 但似乎我无法让我所做的更改 例如通过 setCellValue
  • Grails:映射同一类型的字段和belongsTo的列名

    我正在尝试映射此类的列名称 class Amount String total Total amount of something String type Type of amount Dollars Times something Bon
  • 使用 jq/yq 进行遍历

    我有一个类似于下面的数据文件 user01 name User01 Name age 20 sex male state CA zip 92012 user02 name User02 Name age 22 sex female user
  • Gitlab 与 SonarQube 集成

    我对开发社区 特别是 DevOps 实践还很陌生 作为项目的一部分 我们正在尝试将 SonarQube 与 Gitlab 集成 在 SonarQube 和 Git CI 持续集成 上进行了一些研发 看起来插件已为 Github 和 Sona
  • apache http 基于 ip 重写/重定向

    我想将一个ip重定向到我网站的另一个视图 例如 我希望来自ip x的访问者看到www xxx com DEBUG 1当所有其他访问者看到正常的 www xxx com 时 我该如何在 apache 配置文件中执行此操作 使用哪些指令 下面是
  • 通过 NSUserDefaults 设置 ios UserAgent:工作一半的时间?

    这真让我抓狂 我有两个只是 UIWebView 的应用程序 使用 XCode 4 5 2 和 iOS 6 0 SDK 我想更改网络调用的 UserAgent 我在以下两个地方都使用了这段代码 NSString secretagent MyU
  • Eclipse CDT:禁用红色下划线

    我使用 eclipse cdt 并且包含了一些文件 不幸的是 我无法将包含路径添加到我的 Eclipse 项目中 因为这样当 Eclipse 开始对新添加的包含进行索引时 它总是会崩溃 因此我想关闭突出显示错误的功能 我可以在哪里执行此操作
  • 选择字段中的 Django 空标签 - 没有查询集

    在选择字段上设置空标签给我带来了一些问题 我看过类似的答案this https stackoverflow com questions 14541074 empty label choicefield django 但这只是谈论形式 假设我
  • Swift Core 数据与 Web 服务器同步

    我正在制作一个应用程序 在 Swift 中 需要在离线和在线模式下运行 当处于离线模式时 数据将存储在本地 CoreData 上 一旦检测到网络 在线 它应该与服务器同步并更新后端数据库 应该怎样做呢 有库或 Pod 吗 我见过这个帖子 h
  • 批量从文件中读取多行

    我想知道是否有一种方法可以从文件中批量读取多行 例如 with open filename rb as f for n lines in f process n lines 在这个函数中 我想做的是 对于每次迭代 将从文件中批量读取接下来的
  • UITableViewAutomaticDimension 无法按预期工作。迅速

    读完雷 文德利希之后guide https www raywenderlich com 1067 self sizing table view cells对于 自动调整表格视图单元格大小 以及这个问题 https stackoverflow
  • 设置 pygame 混合器的输出设备

    我需要使用 pygame 通过不同的音频设备播放音频文件 显然这可以通过参数来实现devicename在方法中pygame mixer init https www pygame org docs ref mixer html pygame
  • 如果其他变量为 NA,则设置新变量 NA

    我想向我的数据框添加一个新变量 N notNAs 它定义其他变量是否为 NA x y z N notNAs 2 3 NA NA NA 1 3 NA 2 3 5 1 4 4 3 1 不确定为什么这是您想要的输出 但实现此目的的一种可能方法是将
  • Apache Web 服务器不允许我刷新 /about 但在 localhost 上工作正常

    我捆绑了我的一个项目 效果很好 但是 当在路由 about 上点击刷新时 它会显示请求的 URL about 在此服务器上未找到 但是 当我在 Web 服务器上的本地主机上执行此操作时 它在刷新和前进 后退按钮上工作正常 我正在使用 Rea
  • 即使服务器收到成功消息,也无法在我的设备中接收 GCM 消息

    我从 gcm 收到了作为对 Web 服务器 本地主机 的响应的成功消息 但设备未收到该消息 请帮忙 下面是我使用的代码 主要活动 package vitpat placement import java io IOException imp