我最近在写一个程序在进行完本应用的工作后会弹出一个对话框,提示用户是否需要打开新浪微博,如果用户点击是则打开新浪微博。想问各位大神,我后台如何写代码才能正确打开新浪微博?

解决方案 »

  1.   

    ComponentName comp = new ComponentName("包名",
    "Activity"); 
      Intent intent = new Intent(Intent.ACTION_MAIN);
            intent.addCategory(Intent.CATEGORY_LAUNCHER);
            intent.setComponent(comp);
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);startActivity(intent);  
      

  2.   

    要知道新浪的包名
    packgename="com.sina.weibo" classname="com.sina.weibo.MainTabActivity"
    ComponentName comp = new ComponentName("packgename",
    "classname");  
    Intent intent = new Intent(Intent.ACTION_MAIN);
      intent.addCategory(Intent.CATEGORY_LAUNCHER);
      intent.setComponent(comp);
      intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);startActivity(intent); 
      

  3.   

    1.如果新浪微波是一个apk,就用楼上的方法。
    2.如果只是一个http link.
      Intent i = new Intent();
      Uri uri = Uri.parse("http.....");
      i.setAction(Intent.ACTION_VIEW);
      i.setDataAndType(uri, type);
      startActivity(i);
      具体的uri, type的设置,去网上搜索一下吧。
      这样做的目的是,如果有多个浏览器,可以让用户自己选择自己想要的浏览器去看微波