基于android天气预报开发中的分享功能是怎么实现的
现在的分享基本上都是现成:
android 自带分享功能:虽然比较low,而且不同厂家显示的分享面板可能不一样,但是功能是可以用的,如果要开发写高级功能的那么需要使用到第三方的分享啦
/**
* 分享功能
*
* @param context 上下文
* @param activityTitle Activity的名字
* @param msgTitle 消息标题
* @param msgText 消息内容
* @param imgPath 图片路径,不分享图片则传null
*/
public void shareMsg(String activityTitle, String msgTitle, String msgText,
String imgPath) {
Intent intent = new Intent(Intent.ACTION_SEND);
if (imgPath == null || imgPath.equals("")) {
intent.setType("text/plain"); // 纯文本
} else {
File f = new File(imgPath);
if (f != null f.exists() f.isFile()) {
intent.setType("image/jpg");
Uri u = Uri.fromFile(f);
intent.putExtra(Intent.EXTRA_STREAM, u);
}
}
intent.putExtra(Intent.EXTRA_SUBJECT, msgTitle);
intent.putExtra(Intent.EXTRA_TEXT, msgText);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(Intent.createChooser(intent, activityTitle));
}3. 第三方分享:使用较多的分享-Umeng(友盟),链接:
4. 第三方分享:使用较多的分享-ShareSDK ,链接:
如何在android中开发个天气预报的应用
恩,调用谷歌天气预报的api,返回xml,解析一下显示在控件里就可以了!
基于android的天气预报系统?
用你手机自带的“应用商店”,搜索天气,出来的都是适配你手机系统的天气预报app。
当然,你的手机是安卓的,那就是适配安卓系统的了。
如何自己动手做一个android天气预报的app
一个Android天气预报要用到的代码文件,可显示操作菜单,显示未来四天天气、将全国城市列表写入数据库、初始化数据解析类,界面控件,消息接收器Handler、线程消息接收器、左侧菜单选择事件监听、后退按钮监听等,代码为:
227
if(mycitys.size()==1){
228
showToast("至少要保留一个城市");
229
}else{
230
mycitys.remove(position);
231
writeMyCitys();
232
sAdapter.notifyDataSetChanged();
233
currCityId=mycitys.get(0).get("cityId");
234
changeSearchState();
235
}
236
}
237
});
238
builder.setNegativeButton("取 消",
239
new DialogInterface.OnClickListener() {
240
public void onClick(DialogInterface dialog, int which) {
241
dialog.dismiss();
242
}
243
});
244
builder.show();
245
return false;
246
}
247
//
监听后退按钮
248
@Override
249
public boolean
onKeyDown(int
keyCode, KeyEvent event) {
250
if (keyCode ==
KeyEvent.KEYCODE_BACK) {
251
// 如果当前menu没有显示
252
if (!isBack) {
253
showToast("再按一次退出");
254
downTime = event.getDownTime();
255
isBack = true;
256
return true;
257
} else {
258
if (event.getDownTime() -
downTime = 2000) {
259
AppManager.getAppManager().AppExit(Weather.this);
260
} else {
261
showToast("再按一次退出");
262
downTime = event.getDownTime();
263
return true;
264
}
265
}
266
}
267
return super.onKeyDown(keyCode, event);
268
}
269
@Override
270
protected void
onDestroy() {
271
if(mVibrator!=null){
272
mVibrator.cancel();
273
}
274
super.onDestroy();
275
}
276
}