• Android Intent


    1. make a app as browser, register in AndroidManifest.xml

    <intent-filter>
                    <action android:name="android.intent.action.VIEW"/>
                    <category android:name="android.intent.category.BROWSABLE"/>
                    <category android:name="andoid.intent.category.DEFAULT" />
                    <data android:scheme="http"/>
                </intent-filter>

    http://blog.vogella.com/2011/02/21/android-intents/               Registering for Android Intents – Being a crappy browser

    2. start another activity

    Intent intent = null;
    intent = new Intent(CurrentActivity.this, AnotherActivity.class);
    startActivity(intent);

    3. start activity for result

    static private final int GET_TEXT_REQUEST_CODE = 1;// TODO - Start an Activity using that intent and the request code defined above
    Intent explicitIntent = new Intent(CurrentActivity.this,AnotherActivity.class); 
    startActivityForResult(explicitIntent, GET_TEXT_REQUEST_CODE);

    this method onActivityResult() will be called after AnotherActivity return(finish)

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data)

     in AnotherActivity: set result and finish

    Intent intent = new Intent();
    intent.putExtra("hello", input);
    this.setResult(RESULT_OK, intent);
    finish();

    4. create chooser, let user select from a list of app to handle this request

    Intent baseIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.google.com"));
    
    Intent chooserIntent = Intent.createChooser(baseIntent, CHOOSER_TEXT);
    
    startActivity(chooserIntent);

    5. start another application

      in current application

    startActivity(new Intent("course.labs.permissions.DANGEROUS_ACTIVITY"));

      in another application's AndroidManifest.xml

    <intent-filter>
                    <action android:name="course.labs.permissions.DANGEROUS_ACTIVITY" />
    
                    <category android:name="android.intent.category.DEFAULT" />
    </intent-filter>
  • 相关阅读:
    Apollo,Python,Delphi与Oracle之间的神话关系
    Delphi语言获得生命的原因和过程
    cocos2d(x) HTML label ;CCHTML CCHTMLLabel
    不重启使XP环境变量生效
    对当下纷繁乱世的思考框架(核心与边缘,时间与成本)
    晚明一出,明朝不必再穿越了
    常用的Linux终端
    如何发布使用LGPL版Qt的商业软件
    如何制作一个类似Tiny Wings的游戏 Cocos2d-x 2.1.4
    文明之火熊熊燃烧,灼热乃至引燃了周边霉湿的柴草
  • 原文地址:https://www.cnblogs.com/phoenix13suns/p/4080340.html
Copyright © 2020-2023  润新知