Java Code Examples for android.app.Activity#getCallingPackage()
The following examples show how to use
android.app.Activity#getCallingPackage() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ShareCompat.java From letv with Apache License 2.0 | 5 votes |
public static String getCallingPackage(Activity calledActivity) { String result = calledActivity.getCallingPackage(); if (result == null) { return calledActivity.getIntent().getStringExtra(EXTRA_CALLING_PACKAGE); } return result; }
Example 2
Source File: Wechat.java From PretendSharing_Xposed with MIT License | 5 votes |
public static void invoke(Intent realIntent, Activity thatActivity) { String calling = realIntent.getStringExtra("_mmessage_appPackage"); if(calling == null||"".equals(calling)){ calling = thatActivity.getCallingPackage(); //因为我们不是微信 无法获取app包名 if("".equals(calling) || calling == null){ //如果两种方法都失败 Toast.makeText(thatActivity,"抱歉,这个APP不能被伪装",Toast.LENGTH_SHORT).show(); return; } } String callBackClass = calling + ".wxapi.WXEntryActivity"; ComponentName callBackName = new ComponentName(calling,callBackClass); Intent callBackIntent = new Intent(); callBackIntent.putExtra("wx_token_key","com.tencent.mm.openapi.token"); //奇怪的来自微信验证 String stringExtra = "辣鸡腾讯坑我钱财"; int intExtra = 587333634; String stringExtra2 = "com.tencent.mm";//微信验证用 byte[] wechatSign = wechatSign(stringExtra,intExtra,stringExtra2);//微信验证 callBackIntent.putExtra("_mmessage_content",stringExtra); //消息内容? callBackIntent.putExtra("_mmessage_sdkVersion",intExtra); //微信版本.暂时回复常数 未来可能从微信获取 callBackIntent.putExtra("_mmessage_appPackage",stringExtra2); //微信包名? callBackIntent.putExtra("_mmessage_checksum",wechatSign); //checksum callBackIntent.putExtra("_wxapi_command_type",realIntent.getIntExtra("_wxapi_command_type",0)); //命令类型。还给你 callBackIntent.putExtra("_wxapi_baseresp_errcode",0); //错误码/是否成功。0:成功 String tempStr; if((tempStr = realIntent.getStringExtra("_wxapi_baseresp_transaction")) != null) //有的请求没有,很奇怪,可能是旧版分享sdk callBackIntent.putExtra("_wxapi_baseresp_transaction",tempStr); //未知 else callBackIntent.putExtra("_wxapi_baseresp_transaction","1#sep#4#sep#4884235#sep#1504783117034"); callBackIntent.setFlags(272629760); try{ callBackIntent.setComponent(callBackName); thatActivity.startActivity(callBackIntent); }catch (Exception e){ Toast.makeText(thatActivity,"包"+calling+"没有会调活动项。",Toast.LENGTH_SHORT).show(); return; } //Toast.makeText(this,R.string.msg_wechat_share_success,Toast.LENGTH_SHORT).show(); return; }
Example 3
Source File: ShareCompat.java From MiBandDecompiled with Apache License 2.0 | 5 votes |
public static String getCallingPackage(Activity activity) { String s = activity.getCallingPackage(); if (s == null) { s = activity.getIntent().getStringExtra("android.support.v4.app.EXTRA_CALLING_PACKAGE"); } return s; }
Example 4
Source File: ShareCompat.java From CodenameOne with GNU General Public License v2.0 | 3 votes |
/** * Retrieve the name of the package that launched calledActivity from a share intent. * Apps that provide social sharing functionality can use this to provide attribution * for the app that shared the content. * * <p><em>Note:</em> This data may have been provided voluntarily by the calling * application. As such it should not be trusted for accuracy in the context of * security or verification.</p> * * @param calledActivity Current activity that was launched to share content * @return Name of the calling package */ public static String getCallingPackage(Activity calledActivity) { String result = calledActivity.getCallingPackage(); if (result == null) { result = calledActivity.getIntent().getStringExtra(EXTRA_CALLING_PACKAGE); } return result; }
Example 5
Source File: ShareCompat.java From adt-leanback-support with Apache License 2.0 | 3 votes |
/** * Retrieve the name of the package that launched calledActivity from a share intent. * Apps that provide social sharing functionality can use this to provide attribution * for the app that shared the content. * * <p><em>Note:</em> This data may have been provided voluntarily by the calling * application. As such it should not be trusted for accuracy in the context of * security or verification.</p> * * @param calledActivity Current activity that was launched to share content * @return Name of the calling package */ public static String getCallingPackage(Activity calledActivity) { String result = calledActivity.getCallingPackage(); if (result == null) { result = calledActivity.getIntent().getStringExtra(EXTRA_CALLING_PACKAGE); } return result; }
Example 6
Source File: ShareCompat.java From android-recipes-app with Apache License 2.0 | 3 votes |
/** * Retrieve the name of the package that launched calledActivity from a share intent. * Apps that provide social sharing functionality can use this to provide attribution * for the app that shared the content. * * <p><em>Note:</em> This data may have been provided voluntarily by the calling * application. As such it should not be trusted for accuracy in the context of * security or verification.</p> * * @param calledActivity Current activity that was launched to share content * @return Name of the calling package */ public static String getCallingPackage(Activity calledActivity) { String result = calledActivity.getCallingPackage(); if (result == null) { result = calledActivity.getIntent().getStringExtra(EXTRA_CALLING_PACKAGE); } return result; }
Example 7
Source File: ShareCompat.java From V.FlyoutTest with MIT License | 3 votes |
/** * Retrieve the name of the package that launched calledActivity from a share intent. * Apps that provide social sharing functionality can use this to provide attribution * for the app that shared the content. * * <p><em>Note:</em> This data may have been provided voluntarily by the calling * application. As such it should not be trusted for accuracy in the context of * security or verification.</p> * * @param calledActivity Current activity that was launched to share content * @return Name of the calling package */ public static String getCallingPackage(Activity calledActivity) { String result = calledActivity.getCallingPackage(); if (result == null) { result = calledActivity.getIntent().getStringExtra(EXTRA_CALLING_PACKAGE); } return result; }
Example 8
Source File: ShareCompat.java From guideshow with MIT License | 3 votes |
/** * Retrieve the name of the package that launched calledActivity from a share intent. * Apps that provide social sharing functionality can use this to provide attribution * for the app that shared the content. * * <p><em>Note:</em> This data may have been provided voluntarily by the calling * application. As such it should not be trusted for accuracy in the context of * security or verification.</p> * * @param calledActivity Current activity that was launched to share content * @return Name of the calling package */ public static String getCallingPackage(Activity calledActivity) { String result = calledActivity.getCallingPackage(); if (result == null) { result = calledActivity.getIntent().getStringExtra(EXTRA_CALLING_PACKAGE); } return result; }