ConfigureForm form = new ConfigureForm(FormType.submit); form.setPersistentItems(false); form.setDeliverPayloads(true); form.setAccessModel(AccessModel.open); PubSubManager manager = new PubSubManager(connection, "pubsub.communitivity.com"); Node myNode = manager.createNode("http://jabber.org/protocol/geoloc", form); StringBuilder body = new StringBuilder(); //ws for readability body.append("<geoloc xmlns='http://jabber.org/protocol/geoloc' xml:lang='en'>"); body.append(" <country>Italy</country>"); body.append(" <lat>45.44</lat>"); body.append(" <locality>Venice</locality>"); body.append(" <lon>12.33</lon>"); body.append(" <accuracy>20</accuracy>"); body.append("</geoloc>"); SimplePayload payload = new SimplePayload( "geoloc", "http://jabber.org/protocol/geoloc", body.toString()); String itemId = "zz234"; Item<SimplePayload> item = new Item<SimplePayload>(itemId, payload); // Required to recieve the events being published myNode.addItemEventListener(myEventHandler); // Publish item myNode.publish(item);
Or at least that's the hard way :). Just remembered there's a PEPManager now...
PEPProvider pepProvider = new PEPProvider(); pepProvider.registerPEPParserExtension( "http://jabber.org/protocol/tune", new TuneProvider()); ProviderManager.getInstance().addExtensionProvider( "event", "http://jabber.org/protocol/pubsub#event", pepProvider); Tune tune = new Tune("jeff", "1", "CD", "My Title", "My Track"); pepManager.publish(tune);
http://www.igniterealtime.org/fisheye/browse/~raw,r=11613/svn-org/smack/trunk/documentation/extensions/pubsub.html.
developer forum
svn.igniterealtime.org/svn/repos/smack/trunk smack
igniterealtime.org/fisheye/viewrep/svn-org/smack
public boolean onKeyDown(int keyCode, KeyEvent event) {
Log.d(TAG, "onKeyDown");
if (keyCode == KeyEvent.KEYCODE_DPAD_LEFT) {
panWest();
return true;
} else if (keyCode == KeyEvent.KEYCODE_DPAD_RIGHT) {
panEast();
return true;
} else if (keyCode == KeyEvent.KEYCODE_DPAD_UP) {
panNorth();
return true;
} else if (keyCode == KeyEvent.KEYCODE_DPAD_DOWN) {
panSouth();
return true;
}
return false;
}//手机上的导航键代码
别人的解决办法
1.InputMethodManager imm =
(InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
imm.toggleSoftInput(InputMethodManager.SHOW_FORCED,
InputMethodManager.HIDE_IMPLICIT_ONLY);
或者
InputMethodManager imm = (InputMethodManager) TestAppImg.this.getSystemService(Context.INPUT_METHOD_SERVICE);
if(imm != null){ imm.toggleSoftInput(InputMethodManager.SHOW_FORCED,0); }
2.this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
3.private void showVirturalKeyboard(){
Timer timer = new Timer();
timer.schedule(new TimerTask() {
@Override
public void run() {
InputMethodManager m = (InputMethodManager) TestAppImg.this.getSystemService(Context.INPUT_METHOD_SERVICE);
if(m != null){
// m.toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS);
m.toggleSoftInput(0, InputMethodManager.SHOW_IMPLICIT);
}
}
}, 100);
}
然后在oncreat中引用这个方法
4. 如果不行要<activity android:name=".MainActivity"
android:label="@string/app_name"
android:windowSoftInputMode="stateAlwaysVisible" />
5.还不行还需要在模拟机中设置
模拟机中设置 Keyboard Support
因为模拟机中有个设置是默认不自动的
不过无论我怎么设置都不行在模拟机上
http://groups.google.com/group/android-developers/browse%5Fthread/thread/17210d784766602d