我的应用程序接收并分析收到的意图数据(ACTION.SEND)。根据应用程序,Intent在附加功能中有许多细节。
我想要的是我已收到意图的应用程序的packageID?
有没有标准的方法来实现这个目标?
答案 0 :(得分:0)
如果您在应用程序的许多活动中需要此应用程序详细信息,则可以将它们保存到async Task IRunBeforeEachRequest.Execute()
{
_HttpContext.Items[IdentityContextTransactionKey] = _IdentityContext.Database.BeginTransaction(IsolationLevel.ReadCommitted);
_HttpContext.Items[TravellersContextTransactionKey] = _TravellersContext.Database.BeginTransaction(IsolationLevel.ReadCommitted);
}
中并在所有活动中使用它们,而不必每次都将它们作为意图中的附加项传递。你可以这样做,例如:
Shared preferences
然后你就可以得到这样的保存数据:
SharedPreferences.Editor editor = getSharedPreferences(preffName, MODE_PRIVATE).edit(); //preffName is a String variable with the name of your preferences - just use the same string every time
editor.putString("AppName", "MyApplication");
editor.putInt("PackageID", "MyPackageID");
editor.commit();
答案 1 :(得分:0)
阅读此How to find Intent source in Android?之后,似乎不可能或非常棘手的解决方案。没有直接的方法来实现这一目标。啊,Android。