我没有成功回应钛合金的通知。 所有工作的例子都是经典的。虽然我在tiampl.xml中定义了以下活动
如您所见,即使tiapp.xml包含notification.js活动,AndroidManifest.xml也不包含此活动。它应该添加这个!
<id>alloyandroidnotification.example.com</id>
<name>alloyandroidnotification</name>
<activity url="notification.js">
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
我在lib文件夹中定义了notification.js,我的index.js文件是:
function doClick(e) {
var intent = Ti.Android.createIntent({
action: Ti.Android.ACTION_VIEW,
packageName:"alloyandroidnotification.example.com",
className:"alloyandroidnotification.example.com.NotificationActivity"
});
intent.addCategory(Ti.Android.CATEGORY_LAUNCHER);
Titanium.Android.NotificationManager.notify(1, Titanium.Android.createNotification({
contentTitle: "notification",
contentText : "notification",
contentIntent: Ti.Android.createPendingIntent({
intent:intent,
type : Ti.Android.PENDING_INTENT_FOR_ACTIVITY
}),
flags : Titanium.Android.FLAG_AUTO_CANCEL | Titanium.Android.FLAG_SHOW_LIGHTS
}));
}
$.index.open();
的AndroidManifest.xml
<application android:icon="@drawable/appicon" android:label="alloyandroidnotification" android:name="AlloyandroidnotificationApplication" android:debuggable="false" android:theme="@style/Theme.AppCompat">
<activity android:name=".AlloyandroidnotificationActivity" android:label="@string/app_name" android:theme="@style/Theme.Titanium" android:configChanges="keyboardHidden|orientation|screenSize">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity android:name="org.appcelerator.titanium.TiActivity" android:configChanges="keyboardHidden|orientation|screenSize"/>
<activity android:name="org.appcelerator.titanium.TiTranslucentActivity" android:configChanges="keyboardHidden|orientation|screenSize" android:theme="@style/Theme.AppCompat.Translucent"/>
<activity android:name="ti.modules.titanium.ui.android.TiPreferencesActivity" android:configChanges="screenSize"/>
<service android:name="com.appcelerator.analytics.APSAnalyticsService" android:exported="false"/>
</application>
我应该在AndroidManifest.xml中看到错过预期的活动
<android
xmlns:android="http://schemas.android.com/apk/res/android">
<activity url="notificationClick.js">
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
</android>
点击通知后没有任何反应。但是遵循经典的例子。 classic example code that works
答案 0 :(得分:1)
通过tiapp.xml
添加活动的正确方法是将它们添加到<android>
元素下,而不是添加到根级别。见http://docs.appcelerator.com/platform/latest/#!/guide/tiapp.xml_and_timodule.xml_Reference-section-29004921_tiapp.xmlandtimodule.xmlReference-Android-specificsection
答案 1 :(得分:1)
我发现您已使用<activities>
之外的<activity>
使用了网址,否则如果您要<application>
使用<application>
使用<android xmlns:android="http://schemas.android.com/apk/res/android">
<activities>
<activity url="notificationClick.js">
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
</activities>
</android>
,则它也不起作用public class FlowLayoutExample {
public static void main(String [] a) {
final JFrame frame = new JFrame();
frame.setSize(new Dimension(500, 80));
frame.setMinimumSize(new Dimension(350, 80));
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setContentPane(initJPanel());
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
frame.setVisible(true);
}
});
}
private static JPanel initJPanel() {
JPanel panel = new JPanel();
FlowLayout flowLayout = new FlowLayout(FlowLayout.LEFT);
flowLayout.setHgap(25);
panel.setLayout(flowLayout);
panel.setBackground(Color.LIGHT_GRAY);
panel.add(initLabel());
panel.add(initLabel());
panel.add(initLabel());
panel.add(initLabel());
return panel;
}
private static Component initLabel() {
return new JLabel("MyLabel");
}
}
3}}
Code :-
for i in {1..$n}
do
( sh run_sql.sh test.sql touchstone_test & )
done