我发现了如何检测卸载事件并测试以下代码.
在Receiver.java中:
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
Log.d(TAG, "received broadcast : " + action);
}
Run Code Online (Sandbox Code Playgroud)
在manifest.xml中:
<receiver android:name="....base.BaseAppReceiver">
<intent-filter>
<action android:name="android.intent.action.PACKAGE_REMOVED"/>
<data android:scheme="package"/>
</intent-filter>
</receiver>
Run Code Online (Sandbox Code Playgroud)
但它只检测到其他应用程序何时被卸载.我想在卸载"我的"应用程序而不是"其他"应用程序之前做一些事情.请让我知道如果可以,我的应用程序如何检测卸载事件以便在卸载我的应用程序之前处理某些内容.
我使用以下代码.
CAGradientLayer* collectionRadient = [CAGradientLayer layer];
collectionRadient.bounds = self.collectionView.bounds;
collectionRadient.anchorPoint = CGPointZero;
collectionRadient.colors = [NSArray arrayWithObjects:(id)[startColor CGColor],(id)[endColor CGColor], nil];
[self.collectionView.layer insertSublayer:collectionRadient atIndex:0];
Run Code Online (Sandbox Code Playgroud)
但它在包含图像的细胞上绘制.所以没有显示细胞.
我想在Cells下绘制UICollectionView的渐变背景,并在滚动视图时修复它.请告诉我.