zoukankan      html  css  js  c++  java
  • 008、不同程序的彼此调用

    可以通过Intent调用其他程序的功能,不过,必须知道对方应有的包名和需激活的类名
    方法为Intent.setClassName(String packageName, String className)
    注意:className应该为全名,即包名+类名
     
                    try {
                        Intent intent = new Intent();
                        intent.setClassName("com.example.ex_3_25_otheractivity",
                                "com.example.ex_3_25_otheractivity.OtherActivity");
                        intent.putExtra("STR_MESSAGE", "hi,我来自InteractiveActivity哦");
                        InteractiveActivityActivity.this.startActivityForResult(
                                intent, 0);
                    } catch (Exception e) {
                        findViewById(R.id.bt).setEnabled(false);
                        ((TextView) findViewById(R.id.tv))
                                .setText(getString(R.string.err_str));
                    }
    传递的参数必须由被激活的程序来定义,由其提供接口,定义规则
      
     
  • 相关阅读:
    [JSOI2016]最佳团体
    CF125E MST Company
    CF482C Game with Strings
    CF379F New Year Tree
    CF1051F The Shortest Statement
    小a和uim之大逃离
    新魔法药水
    翻硬币
    [CQOI2017]小Q的棋盘
    UVA11729突击战
  • 原文地址:https://www.cnblogs.com/zyh-blog/p/3324496.html
Copyright © 2011-2022 走看看