当前位置: 首页 > 技术分析

基于Android系统(Android Weather App开发教程)的应用程序开发和风天气预报

时间:2023-03-10 00:22:24 技术分析

  目前的共享基本上可用:

  Android具有共享功能:尽管它相对较低,并且不同制造商显示的共享面板可能不同,但是可以使用该功能。如果您想开发高级功能,则需要使用第三方共享。

  /**

  *共享功能

  *

  *@param上下文

  *@param ActivityTitle活动

  *@param msgtitle消息标题

  *@param msgtext消息内容

  *@param imgpath图片路径,传递图片而无需共享

  */

  public void sharemsg(字符串ActivityTital,字符串MSGTITLE,字符串MSGTEXT,字符串MSGTEXT,字符串

  字符串imgpath){

  intent Intert = new Intert(Intent.Action_Send);

  if(imgpath == null || imgpath.equals(“”){{

  intent.setType(“ text/plain”);//纯文本

  } 别的 {

  文件f =新文件(imgpath);

  if(f!= null f.exist()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);

  启动性(Intent.CreateChooser(intent,activyTitle));

  } 3.第三方共享:使用更多共享 - 穆恩(朋友联盟),链接:

  4.第三方共享:使用更多共享-sharesdk,链接:

  好吧,请致电Google的天气预报API,返回XML,然后在控件中进行分析!

  使用您自己的“应用商店”来搜索天气以及适应您的手机系统的天气预报应用程序。

  当然,您的手机是Android,适用于Android系统。

  Android天气预报使用的代码文件可以显示操作菜单,在接下来的四天内显示天气,将国家城市列表写入数据库,初始化数据分析,接口控制,消息接收器处理程序,线程消息接收器,左侧侧面,左侧菜单选择事件监视,返回 - 重新处理按钮监视等。代码是:

  227

  如果(mycitys.size)== 1){{{

  228

  表演(“至少要保留一个城市”);

  229

  } 别的 {

  230

  mycitys.remove(姿势);

  231

  writemycitys();

  232

  sadaapter.notifydatasetchanged();

  233

  currcityid = mycitys.get(0).get(“ cityid”);

  234

  changeEarchState();

  235

  }

  236

  }

  237

  });

  238

  Builder.setnegativeButton(“”

  239

  new DialogInterface.onclicklistener(){

  240

  

  241

  dialog.dismiss();

  242

  }

  243

  });

  244

  builder.show();

  245

  返回false;

  246

  }

  247

  //

  监视后按钮

  248

  @Override

  249

  Boyan公共

  onkeydown(int

  键代码,keyevent事件){

  250

  if(keyCode ==

  keyevent.keycode_back){

  251

  //如果未显示当前菜单

  252

  如果(!isback){

  253

  Showtoast(“按另一个出口”);

  254

  下载= event.getDownTime();

  255

  isback = true;

  256

  返回true;

  257

  } 别的 {

  258

  if(event.getDowntime() -

  下载= 2000){

  259

  AppManager.getAppManager()。AppExit(Weather.this);

  260

  } 别的 {

  261

  Showtoast(“按另一个出口”);

  262

  下载= event.getDownTime();

  263

  返回true;

  264

  }

  265

  }

  266

  }

  267

  返回super.onkeydown(键代码,事件);

  268

  }

  269

  @Override

  270

  受保护的空隙

  ondestroy(){

  271

  如果(mvrator!= null){

  272

  mvrator.cancel();

  273

  }

  274

  super.ndstroy();

  275

  }

  276

  }