我的应用是全屏的,所以我在我的style.xml中使用它:
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowNoTitle">true</item>
<item name="android:windowFullscreen">true</item>
</style>
我实施了上传通知。现在,当你向下滑动应用程序的透明版本时,你如何暂时显示状态栏。
- 编辑 -
public class UploadService extends IntentService {
private NotificationManager mNotificationManager;
public UploadService() {
super("UploadService");
}
@Override
public void onDestroy() {
super.onDestroy();
mNotificationManager.cancel(0);
}
@Override
protected void onHandleIntent(Intent intent) {
Resources resources = getResources();
final Notification uploadNotification = new NotificationCompat.Builder(this)
.setTicker(resources.getString(R.string.upload))
.setSmallIcon(android.R.drawable.ic_menu_upload)
.setContentTitle(resources.getString(R.string.app_name))
.setContentText(resources.getString(R.string.upload_progress))
.setProgress(0, 0, true)
.build();
final Notification failedNotification = new NotificationCompat.Builder(this)
.setSmallIcon(android.R.drawable.ic_menu_report_image)
.setTicker(resources.getString(R.string.upload_failed))
.setContentTitle(resources.getString(R.string.upload_failed))
.setAutoCancel(true)
.build();
mNotificationManager = (NotificationManager)
getSystemService(NOTIFICATION_SERVICE);
mNotificationManager.notify(0, uploadNotification);
ParseFile parseFile = null;
boolean success = true;
Bundle bundle = intent.getBundleExtra("bundleImage");
String userID = bundle.getString("userID");
ParseUser parseUser = ParseUser.createWithoutData(ParseUser.class, userID);
String image = bundle.getString("imagePath");
Uri imageUri = Uri.parse(image);
String filename = bundle.getString("imageName");
ByteArrayOutputStream baos;
InputStream is;
try {
baos = new ByteArrayOutputStream();
is = getContentResolver().openInputStream(imageUri);
Bitmap bitmap = BitmapFactory.decodeStream(is);
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, baos);
parseFile = new ParseFile(filename, baos.toByteArray());
baos.close();
is.close();
} catch (Exception e) {
success = false;
mNotificationManager.notify(0, failedNotification);
}
if (success) {
Frames frames = new Frames();
frames.setUploader(parseUser);
frames.setFrameFile(parseFile);
try {
frames.save();
} catch (ParseException e) {
mNotificationManager.notify(0, failedNotification);
}
}
}
答案 0 :(得分:1)
您可以覆盖onTouchEvent
,只需添加/清除FLAG_FULLSCREEN
标记。
public boolean mIsVisible = false;
...
...
@Override
public boolean onTouchEvent(MotionEvent event)
{
if ( event.getAction() == MotionEvent.ACTION_DOWN )
{
if ( mIsVisible)
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
else
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
mIsVisible = !mIsVisible;
}
return super.onTouchEvent(event);
}