auto import from //depot/cupcake/@135843
This commit is contained in:
@@ -1,72 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2007 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.development;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.net.Uri;
|
||||
import android.os.Environment;
|
||||
import android.widget.TextView;
|
||||
|
||||
public class MediaScannerActivity extends Activity
|
||||
{
|
||||
public MediaScannerActivity() {
|
||||
}
|
||||
|
||||
/** Called when the activity is first created or resumed. */
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
|
||||
setContentView(R.layout.media_scanner_activity);
|
||||
|
||||
IntentFilter intentFilter = new IntentFilter(Intent.ACTION_MEDIA_SCANNER_STARTED);
|
||||
intentFilter.addAction(Intent.ACTION_MEDIA_SCANNER_FINISHED);
|
||||
intentFilter.addDataScheme("file");
|
||||
registerReceiver(mReceiver, intentFilter);
|
||||
|
||||
sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri.parse("file://"
|
||||
+ Environment.getExternalStorageDirectory())));
|
||||
|
||||
mTitle = (TextView) findViewById(R.id.title);
|
||||
mTitle.setText("Sent ACTION_MEDIA_MOUNTED to trigger the Media Scanner.");
|
||||
}
|
||||
|
||||
/** Called when the activity going into the background or being destroyed. */
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
unregisterReceiver(mReceiver);
|
||||
}
|
||||
|
||||
private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
if (intent.getAction().equals(Intent.ACTION_MEDIA_SCANNER_STARTED)) {
|
||||
mTitle.setText("Media Scanner started scanning " + intent.getData().getPath());
|
||||
}
|
||||
else if (intent.getAction().equals(Intent.ACTION_MEDIA_SCANNER_FINISHED)) {
|
||||
mTitle.setText("Media Scanner finished scanning " + intent.getData().getPath());
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
private TextView mTitle;
|
||||
}
|
||||
Reference in New Issue
Block a user