我已经编写了这个安卓代码,但它没有工作或点击时显示任何内容。我在此代码中没有XML活动。
public Pro(Game game) {
super(game);
}
@Override
public void update(float deltaTime) {
Graphics g = game.getGraphics();
List<TouchEvent> touchEvents = game.getInput().getTouchEvents();
int len1 = touchEvents.size();
for (int i = 0; i < len1; i++) {
TouchEvent event = touchEvents.get(i);
if (event.type == TouchEvent.TOUCH_UP) {
if (inBounds(event, 550, 350, 350, 450)) {
try {
URI uri = new URI("www.google.com");
} catch (URISyntaxException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}
}
private boolean inBounds(TouchEvent event, int x, int y, int width,
int height) {
if (event.x > x && event.x < x + width - 1 && event.y > y
&& event.y < y + height - 1)
return true;
else
return false;
}
请帮我解决问题。
答案 0 :(得分:1)
如果您想使用此URL打开浏览器,请按照此问题的答案进行操作 Sending an Intent to browser to open specific URL
答案 1 :(得分:0)
URI uri =新URI(“www.google.com”);这根本不起作用。
startActivity(new Intent(Intent.ACTION_VIEW,Uri.parse(“http://www.google.com”)));