安卓发送大量短信的 [英] Android sending lots of SMS messages

查看:215
本文介绍了安卓发送大量短信的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序,它发送大量的SMS消息到中央服务器。每个用户可能会发送〜300 txts /天。短信被用作一个网络层,因为短信是几乎无处不在,移动互联网是没有的。该应用程序是为在许多第三世界国家,其中移动互联网是不是无处不在。

I have a app, which sends a lot of SMS messages to a central server. Each user will probably send ~300 txts/day. SMS messages are being used as a networking layer, because SMS is almost everywhere and mobile internet is not. The app is intended for use in a lot of 3rd world countries where mobile internet is not ubiquitous.

当我打100封邮件的限制,我得到的发送每封邮件的提示。提示说,正在发送大量短信的。这是不正常的获得每次问,如果应用程序可以发送短信提示用户。用户不希望得到连续30提示。

When I hit a limit of 100 messages, I get a prompt for each message sent. The prompt says "A large number of SMS messages are being sent". This is not ok for the user to get prompted each time to ask if the app can send a text message. The user doesn't want to get 30 consecutive prompts.

我发现谷歌这款Android的源文件。它可能是过时的,我也说不清。它看起来像有100短信的限制每3600000ms(1天)为每个应用程序。

I found this android source file with google. It could be out of date, I can't tell. It looks like there is a limit of 100 sms messages every 3600000ms(1 day) for each application.

<一个href="http://www.netmite.com/android/mydroid/frameworks/base/telephony/java/com/android/internal/telephony/gsm/SMSDispatcher.java">http://www.netmite.com/android/mydroid/frameworks/base/telephony/java/com/android/internal/telephony/gsm/SMSDispatcher.java

/** Default checking period for SMS sent without uesr permit */
private static final int DEFAULT_SMS_CHECK_PERIOD = 3600000;

/** Default number of SMS sent in checking period without uesr permit */
private static final int DEFAULT_SMS_MAX_ALLOWED = 100;

/**
 *  Implement the per-application based SMS control, which only allows
 *  a limit on the number of SMS/MMS messages an app can send in checking
 *  period.
 */
private class SmsCounter {
    private int mCheckPeriod;
    private int mMaxAllowed;
    private HashMap<String, ArrayList<Long>> mSmsStamp;

    /**
     * Create SmsCounter
     * @param mMax is the number of SMS allowed without user permit
     * @param mPeriod is the checking period
     */
    SmsCounter(int mMax, int mPeriod) {
        mMaxAllowed = mMax;
        mCheckPeriod = mPeriod;
        mSmsStamp = new HashMap<String, ArrayList<Long>> ();
    }

    boolean check(String appName) {
        if (!mSmsStamp.containsKey(appName)) {
            mSmsStamp.put(appName, new ArrayList<Long>());
        }

        return isUnderLimit(mSmsStamp.get(appName));
    }

    private boolean isUnderLimit(ArrayList<Long> sent) {
        Long ct =  System.currentTimeMillis();

        Log.d(TAG, "SMS send size=" + sent.size() + "time=" + ct);

        while (sent.size() > 0 && (ct - sent.get(0)) > mCheckPeriod ) {
                sent.remove(0);
        }

        if (sent.size() < mMaxAllowed) {
            sent.add(ct);
            return true;
        }
        return false;
    }
}

这是连真正的Andr​​oid code?它看起来就像是在包com.android.internal.telephony.gsm,我找不到这个包对Android的网站。

Is this even the real android code? It looks like it is in the package "com.android.internal.telephony.gsm", I can't find this package on the android website.

我如何可以禁用/修改此限制?我一直在使用Google的解决方案,但我没有发现任何东西。

How can I disable/modify this limit? I've been googling for solutions, but I haven't found anything.

所以,我一直在寻找那个commonsware.com张贴链接,我发现,源实际上已经改变。所以,我可能仍然有一个镜头。

So I was looking at the link that commonsware.com posted, and I found that the source had actually changed. And so I might still have a shot.

    int check_period = Settings.Gservices.getInt(mResolver,
            Settings.Gservices.SMS_OUTGOING_CEHCK_INTERVAL_MS,
            DEFAULT_SMS_CHECK_PERIOD);
    int max_count = Settings.Gservices.getInt(mResolver,
            Settings.Gservices.SMS_OUTGOING_CEHCK_MAX_COUNT,
            DEFAULT_SMS_MAX_COUNT);
    mCounter = new SmsCounter(max_count, check_period);

这是从设定表得到checkPeriod和MAXCOUNT。但我似乎并没有获得相同的表。该来源应该是安卓1.1,这是我使用的是相同的。当我尝试导入android.provider.Settings.Gservices,我得到一个错误说,进口无法得到解决。

This is getting checkPeriod and maxCount from a settings table. But I don't seem to have access to the same table. That source should be Android 1.1, which is the same I'm using. When I try to import android.provider.Settings.Gservices, I get an error saying that the import can't be resolved.

这是怎么回事?

推荐答案

您是否尝试过使用导入android.provider.Settings;而不是进口android.provider.Settings.GServices? (见<一行36 href="http://www.google.com/$c$csearch/p?hl=en&sa=N&cd=1&ct=rc#uX1GffpyOZk/telephony/java/com/android/internal/telephony/gsm/SMSDispatcher.java&q=package%3Aandroid%20SmsCounter"相对=nofollow> SMSDispatcher.java )

Did you try using "import android.provider.Settings;" instead of "import android.provider.Settings.GServices"? (see line 36 of SMSDispatcher.java)

另外,不知道它有多大的重要性,但3600000毫秒是一个小时的不是一天。

Also, not sure how much difference it makes, but 3600000 ms is one hour not one day.

这篇关于安卓发送大量短信的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆