0

我正在尝试制作一个可以在服务调用上向 AIR 发送事件的 ANE。创建服务时我没有错误,但我的广播似乎没有被调用。这是我的 AlarmCreation(我删除了不必要的代码)

 public FREObject call(FREContext context, FREObject[] args) {

        FREObject pData = args[0];

        myUserData = new AlarmInterfaceUserData();
        myUserData.setContext(context);

        myUserData.setsHeure(pData.getProperty("heures").getAsString());
        myUserData.setsDate(pData.getProperty("jours").getAsString());
        myUserData.setbRepeat(pData.getProperty("repeat").getAsBool());


        String[] sHeures = myUserData.getsHeure().split(":");
        String[] sDates = myUserData.getsDate().split("-");
        Boolean bRepeat = myUserData.isbRepeat();

        String sTemp1 = null;

        Context myAppContext = context.getActivity().getApplicationContext();

        Intent myIntent = new Intent("com.atnetplanet.alarmInterface.BroadcastReceiver");
        myIntent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
        myIntent.putExtra("repeatWhenTime", false);

        for(String sDay : sDates){
            int iDay;
            if(sDay == "SUNDAY") iDay = 1;
            else if(sDay == "MONDAY") iDay = 2;
            else if(sDay == "TUESDAY") iDay = 3;
            else if(sDay == "WEDNESDAY") iDay = 4;
            else if(sDay == "THURSDAY") iDay = 5;
            else if(sDay == "FRIDAY") iDay = 6;
            else iDay = 7;

            String sTemp2 = Long.toString(System.currentTimeMillis());
            sTemp2 = sTemp2.substring(sTemp2.length()-10, sTemp2.length());

            Integer nCodeAlarm = 123456;
            myIntent.putExtra("id", nCodeAlarm);

            PendingIntent myAlarmIntent = PendingIntent.getBroadcast(myAppContext, nCodeAlarm, myIntent, 0);

            AlarmManager myAlarmManager = (AlarmManager)context.getActivity().getSystemService(ALARM_SERVICE);
            Calendar myCalendar = Calendar.getInstance();
            myCalendar.set(Calendar.DAY_OF_WEEK, iDay);
            myCalendar.set(Calendar.HOUR_OF_DAY, Integer.parseInt(sHeures[0]));
            myCalendar.set(Calendar.MINUTE, Integer.parseInt(sHeures[1]));
            myCalendar.set(Calendar.SECOND, 0);
            myCalendar.set(Calendar.MILLISECOND, 0);

            if(bRepeat == true){
                myAlarmManager.setRepeating(AlarmManager.RTC_WAKEUP, myCalendar.getTimeInMillis(), AlarmManager.INTERVAL_DAY, myAlarmIntent);
            } else{
                myAlarmManager.set(AlarmManager.RTC_WAKEUP, myCalendar.getTimeInMillis(), myAlarmIntent);
            }


            if(sTemp1 == null)
                sTemp1 = Integer.toString(nCodeAlarm);
            else
                sTemp1 = sTemp1+"/"+Integer.toString(nCodeAlarm);   
        }

        FREObject mesAlarm = null;
        try {
            mesAlarm = FREObject.newObject(sTemp1);
        } catch (FREWrongThreadException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        return mesAlarm;

    }

我的广播接收器现在非常简单

 public void onReceive(Context context, Intent intent) {
        Toast.makeText(context, "On recupere une alarme", Toast.LENGTH_LONG).show();


        myUserData = AlarmInterfaceUserData.getInstance();
        myUserData.getContext().dispatchStatusEventAsync("DATA_CHANGED", "Faut se reveiller");

    }

最后是我的清单

    <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      android:versionCode="1"
      android:versionName="1.0" package="com.atnetplanet">

    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.VIBRATE" />
    <uses-permission android:name="android.permission.WAKE_LOCK" />
    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
    <uses-permission android:name="android.permission.DISABLE_KEYGUARD"/>

    <application android:icon="@drawable/icon" android:label="@string/app_name" android:debuggable="true">
        <activity
            android:name="com.atnetplanet.alarminterface.AlarmInterfaceCreateAlarmFunction"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <!--<action android:name="android.intent.action.SET_ALARM"/>
                <category android:name="android.intent.category.LAUNCHER" />-->
            </intent-filter>
        </activity>

        <activity android:name="com.atnetplanet.alarminterface.AlarmInterfaceDispatchAlarm"
            android:screenOrientation="portrait">
        </activity>

        <receiver 
            android:name="com.atnetplanet.alarminterface.AlarmInterfaceBroadcastReceiver" 
            android:enabled="true" android:exported="true" android:process=":remote">
            <intent-filter >
                <action android:name="android.intent.action.BOOT_COMPLETED"/>
            </intent-filter>
        </receiver>
        <service android:enabled="true" android:exported="true" android:name="com.atnetplanet.alarminterface.AlarmInterfaceDispatchAlarm" />
    </application>
</manifest>

如果有人能给我一些情报,我会非常有帮助。

谢谢你。

4

1 回答 1

0

使用您的清单,您需要确保所有添加都在您的 AIR 应用程序描述符中。使用您的库创建的实际 AndroidManifest.xml 文件永远不会被 AIR 应用程序使用。

于 2014-07-08T23:54:08.100 回答