- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我真的需要一些帮助来解决我在从一个 Activity 切换到另一个 Activity 时遇到的泄漏。我正在尝试使用 YouTube Android API,我将播放列表加载到一些可点击的缩略图中,然后它们播放视频。一切似乎都正常,但后来我注意到 Logcat 中存在漏洞。
这是我的代码:
public class MainActivity extends Activity implements
OnInitializedListener,
YouTubeThumbnailLoader.OnThumbnailLoadedListener, OnClickListener {
YouTubeThumbnailView thumbs1, thumbs2, thumbs3, thumbs4, thumbs5
YouTubeThumbnailLoader Loader;
ImageView play1, play2, play3, play4, play5;
RelativeLayout tempLayout;
public static final String DEVELOPER_KEY = "xxxxxxxxxxxxxxxxxxxxxxxx";
String videolist, taal;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_main);
tempLayout = (RelativeLayout) findViewById(R.id.tempLayout);
tempLayout.setVisibility(View.VISIBLE);
taal = Locale.getDefault().getLanguage();
if(taal.equals("nl")){
videolist = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
}else{
videolist = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
}
play1 = (ImageView) findViewById(R.id.play1);
play2 = (ImageView) findViewById(R.id.play2);
play3 = (ImageView) findViewById(R.id.play3);
play4 = (ImageView) findViewById(R.id.play4);
play5 = (ImageView) findViewById(R.id.play5);
play1.setVisibility(View.INVISIBLE);
play2.setVisibility(View.INVISIBLE);
play3.setVisibility(View.INVISIBLE);
play4.setVisibility(View.INVISIBLE);
play5.setVisibility(View.INVISIBLE);
thumbs1 = (YouTubeThumbnailView) findViewById(R.id.thumbs1);
thumbs2 = (YouTubeThumbnailView) findViewById(R.id.thumbs2);
thumbs3 = (YouTubeThumbnailView) findViewById(R.id.thumbs3);
thumbs4 = (YouTubeThumbnailView) findViewById(R.id.thumbs4);
thumbs5 = (YouTubeThumbnailView) findViewById(R.id.thumbs5);
thumbs1.initialize(DEVELOPER_KEY, this);
thumbs2.initialize(DEVELOPER_KEY, this);
thumbs3.initialize(DEVELOPER_KEY, this);
thumbs4.initialize(DEVELOPER_KEY, this);
thumbs5.initialize(DEVELOPER_KEY, this);
}
@Override
public void onInitializationFailure(YouTubeThumbnailView v,
YouTubeInitializationResult arg1) {
// TODO Auto-generated method stub
tempLayout.setVisibility(View.INVISIBLE);
Toast.makeText( this,"Unable to initialize",Toast.LENGTH_LONG).show();
}
@Override
public void onInitializationSuccess(YouTubeThumbnailView v,
YouTubeThumbnailLoader loader) {
// TODO Auto-generated method stub
this.Loader = loader;
Loader.setOnThumbnailLoadedListener(this);
if (v == thumbs1)
Loader.setPlaylist(videolist, 0);
if (v == thumbs2)
Loader.setPlaylist(videolist, 1);
if (v == thumbs3)
Loader.setPlaylist(videolist, 2);
if (v == thumbs4)
Loader.setPlaylist(videolist, 3);
if (v == thumbs5)
Loader.setPlaylist(videolist, 4);
}
@Override
public void onThumbnailError(YouTubeThumbnailView v, ErrorReason arg1) {
// TODO Auto-generated method stub
if (isOnline() == true) {
tempLayout.setVisibility(View.INVISIBLE);
if (v == thumbs1)
play1.setImageResource(R.drawable.unav);
play1.setVisibility(View.VISIBLE);
if (v == thumbs2)
play2.setImageResource(R.drawable.unav);
play2.setVisibility(View.VISIBLE);
if (v == thumbs3)
play3.setImageResource(R.drawable.unav);
play3.setVisibility(View.VISIBLE);
if (v == thumbs4)
play4.setImageResource(R.drawable.unav);
play4.setVisibility(View.VISIBLE);
if (v == thumbs5)
play5.setImageResource(R.drawable.unav);
play5.setVisibility(View.VISIBLE);
} else {
tempLayout.setVisibility(View.INVISIBLE);
Toast.makeText(this,
"Error: "+ arg1",
Toast.LENGTH_LONG).show();
}
}
@Override
public void onThumbnailLoaded(YouTubeThumbnailView v, String arg1) {
// TODO Auto-generated method stub
tempLayout.setVisibility(View.INVISIBLE);
play1.setVisibility(View.VISIBLE);
play2.setVisibility(View.VISIBLE);
play3.setVisibility(View.VISIBLE);
play4.setVisibility(View.VISIBLE);
play5.setVisibility(View.VISIBLE);
v.setTag(arg1);
v.setOnClickListener(this);
}
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
String vid = v.getTag().toString();
if(Loader != null){
Loader.release();
Loader = null;
}
Intent intent = new Intent(MainActivity.this, PlayerActivity.class);
intent.putExtra("play", vid);
startActivity(intent);
finish();
}
public boolean isOnline() {
ConnectivityManager CM = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo nwi = CM.getActiveNetworkInfo();
if (netInfo != null && nwi.isConnected()) {
return true;
}
return false;
}
}
现在这是我通过单击缩略图完成 Activity 时的 LogCat 输出,因此 onClick 方法中的代码:
01-30 19:29:04.122: E/ActivityThread(21292): Activity com.reemdroid.tube.MainActivity has leaked ServiceConnection com.google.android.youtube.player.internal.r$e@42f42c50 that was originally bound here
01-30 19:29:04.122: E/ActivityThread(21292): android.app.ServiceConnectionLeaked: Activity com.reemdroid.tube.MainActivity has leaked ServiceConnection com.google.android.youtube.player.internal.r$e@42f42c50 that was originally bound here
01-30 19:29:04.122: E/ActivityThread(21292): at android.app.LoadedApk$ServiceDispatcher.<init>(LoadedApk.java:969)
01-30 19:29:04.122: E/ActivityThread(21292): at android.app.LoadedApk.getServiceDispatcher(LoadedApk.java:863)
01-30 19:29:04.122: E/ActivityThread(21292): at android.app.ContextImpl.bindService(ContextImpl.java:1418)
01-30 19:29:04.122: E/ActivityThread(21292): at android.app.ContextImpl.bindService(ContextImpl.java:1407)
01-30 19:29:04.122: E/ActivityThread(21292): at android.content.ContextWrapper.bindService(ContextWrapper.java:473)
01-30 19:29:04.122: E/ActivityThread(21292): at com.google.android.youtube.player.internal.r.e(Unknown Source)
01-30 19:29:04.122: E/ActivityThread(21292): at com.google.android.youtube.player.YouTubeThumbnailView.initialize(Unknown Source)
01-30 19:29:04.122: E/ActivityThread(21292): at com.reemdroid.tube.MainActivity.onCreate(MainActivity.java:140)
01-30 19:29:04.122: E/ActivityThread(21292): at android.app.Activity.performCreate(Activity.java:5104)
01-30 19:29:04.122: E/ActivityThread(21292): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
01-30 19:29:04.122: E/ActivityThread(21292): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
01-30 19:29:04.122: E/ActivityThread(21292): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
01-30 19:29:04.122: E/ActivityThread(21292): at android.app.ActivityThread.access$600(ActivityThread.java:141)
01-30 19:29:04.122: E/ActivityThread(21292): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
01-30 19:29:04.122: E/ActivityThread(21292): at android.os.Handler.dispatchMessage(Handler.java:99)
01-30 19:29:04.122: E/ActivityThread(21292): at android.os.Looper.loop(Looper.java:137)
01-30 19:29:04.122: E/ActivityThread(21292): at android.app.ActivityThread.main(ActivityThread.java:5039)
01-30 19:29:04.122: E/ActivityThread(21292): at java.lang.reflect.Method.invokeNative(Native Method)
01-30 19:29:04.122: E/ActivityThread(21292): at java.lang.reflect.Method.invoke(Method.java:511)
01-30 19:29:04.122: E/ActivityThread(21292): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
01-30 19:29:04.122: E/ActivityThread(21292): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
01-30 19:29:04.122: E/ActivityThread(21292): at dalvik.system.NativeStart.main(Native Method)
01-30 19:29:04.132: E/ActivityThread(21292): Activity com.reemdroid.tube.MainActivity has leaked ServiceConnection com.google.android.youtube.player.internal.r$e@42f23660 that was originally bound here
01-30 19:29:04.132: E/ActivityThread(21292): android.app.ServiceConnectionLeaked: Activity com.reemdroid.tube.MainActivity has leaked ServiceConnection com.google.android.youtube.player.internal.r$e@42f23660 that was originally bound here
01-30 19:29:04.132: E/ActivityThread(21292): at android.app.LoadedApk$ServiceDispatcher.<init>(LoadedApk.java:969)
01-30 19:29:04.132: E/ActivityThread(21292): at android.app.LoadedApk.getServiceDispatcher(LoadedApk.java:863)
01-30 19:29:04.132: E/ActivityThread(21292): at android.app.ContextImpl.bindService(ContextImpl.java:1418)
01-30 19:29:04.132: E/ActivityThread(21292): at android.app.ContextImpl.bindService(ContextImpl.java:1407)
01-30 19:29:04.132: E/ActivityThread(21292): at android.content.ContextWrapper.bindService(ContextWrapper.java:473)
01-30 19:29:04.132: E/ActivityThread(21292): at com.google.android.youtube.player.internal.r.e(Unknown Source)
01-30 19:29:04.132: E/ActivityThread(21292): at com.google.android.youtube.player.YouTubeThumbnailView.initialize(Unknown Source)
01-30 19:29:04.132: E/ActivityThread(21292): at com.reemdroid.tube.MainActivity.onCreate(MainActivity.java:129)
01-30 19:29:04.132: E/ActivityThread(21292): at android.app.Activity.performCreate(Activity.java:5104)
01-30 19:29:04.132: E/ActivityThread(21292): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
01-30 19:29:04.132: E/ActivityThread(21292): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
01-30 19:29:04.132: E/ActivityThread(21292): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
01-30 19:29:04.132: E/ActivityThread(21292): at android.app.ActivityThread.access$600(ActivityThread.java:141)
01-30 19:29:04.132: E/ActivityThread(21292): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
01-30 19:29:04.132: E/ActivityThread(21292): at android.os.Handler.dispatchMessage(Handler.java:99)
01-30 19:29:04.132: E/ActivityThread(21292): at android.os.Looper.loop(Looper.java:137)
01-30 19:29:04.132: E/ActivityThread(21292): at android.app.ActivityThread.main(ActivityThread.java:5039)
01-30 19:29:04.132: E/ActivityThread(21292): at java.lang.reflect.Method.invokeNative(Native Method)
01-30 19:29:04.132: E/ActivityThread(21292): at java.lang.reflect.Method.invoke(Method.java:511)
01-30 19:29:04.132: E/ActivityThread(21292): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
01-30 19:29:04.132: E/ActivityThread(21292): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
01-30 19:29:04.132: E/ActivityThread(21292): at dalvik.system.NativeStart.main(Native Method)
01-30 19:29:04.132: E/ActivityThread(21292): Activity com.reemdroid.tube.MainActivity has leaked ServiceConnection com.google.android.youtube.player.internal.r$e@42f3d140 that was originally bound here
01-30 19:29:04.132: E/ActivityThread(21292): android.app.ServiceConnectionLeaked: Activity com.reemdroid.tube.MainActivity has leaked ServiceConnection com.google.android.youtube.player.internal.r$e@42f3d140 that was originally bound here
01-30 19:29:04.132: E/ActivityThread(21292): at android.app.LoadedApk$ServiceDispatcher.<init>(LoadedApk.java:969)
01-30 19:29:04.132: E/ActivityThread(21292): at android.app.LoadedApk.getServiceDispatcher(LoadedApk.java:863)
01-30 19:29:04.132: E/ActivityThread(21292): at android.app.ContextImpl.bindService(ContextImpl.java:1418)
01-30 19:29:04.132: E/ActivityThread(21292): at android.app.ContextImpl.bindService(ContextImpl.java:1407)
01-30 19:29:04.132: E/ActivityThread(21292): at android.content.ContextWrapper.bindService(ContextWrapper.java:473)
01-30 19:29:04.132: E/ActivityThread(21292): at com.google.android.youtube.player.internal.r.e(Unknown Source)
01-30 19:29:04.132: E/ActivityThread(21292): at com.google.android.youtube.player.YouTubeThumbnailView.initialize(Unknown Source)
01-30 19:29:04.132: E/ActivityThread(21292): at com.reemdroid.tube.MainActivity.onCreate(MainActivity.java:138)
01-30 19:29:04.132: E/ActivityThread(21292): at android.app.Activity.performCreate(Activity.java:5104)
01-30 19:29:04.132: E/ActivityThread(21292): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
01-30 19:29:04.132: E/ActivityThread(21292): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
01-30 19:29:04.132: E/ActivityThread(21292): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
01-30 19:29:04.132: E/ActivityThread(21292): at android.app.ActivityThread.access$600(ActivityThread.java:141)
01-30 19:29:04.132: E/ActivityThread(21292): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
01-30 19:29:04.132: E/ActivityThread(21292): at android.os.Handler.dispatchMessage(Handler.java:99)
01-30 19:29:04.132: E/ActivityThread(21292): at android.os.Looper.loop(Looper.java:137)
01-30 19:29:04.132: E/ActivityThread(21292): at android.app.ActivityThread.main(ActivityThread.java:5039)
01-30 19:29:04.132: E/ActivityThread(21292): at java.lang.reflect.Method.invokeNative(Native Method)
01-30 19:29:04.132: E/ActivityThread(21292): at java.lang.reflect.Method.invoke(Method.java:511)
01-30 19:29:04.132: E/ActivityThread(21292): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
01-30 19:29:04.132: E/ActivityThread(21292): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
01-30 19:29:04.132: E/ActivityThread(21292): at dalvik.system.NativeStart.main(Native Method)
01-30 19:29:04.142: E/ActivityThread(21292): Activity com.reemdroid.tube.MainActivity has leaked ServiceConnection com.google.android.youtube.player.internal.r$e@42f291f8 that was originally bound here
01-30 19:29:04.142: E/ActivityThread(21292): android.app.ServiceConnectionLeaked: Activity com.reemdroid.tube.MainActivity has leaked ServiceConnection com.google.android.youtube.player.internal.r$e@42f291f8 that was originally bound here
01-30 19:29:04.142: E/ActivityThread(21292): at android.app.LoadedApk$ServiceDispatcher.<init>(LoadedApk.java:969)
01-30 19:29:04.142: E/ActivityThread(21292): at android.app.LoadedApk.getServiceDispatcher(LoadedApk.java:863)
01-30 19:29:04.142: E/ActivityThread(21292): at android.app.ContextImpl.bindService(ContextImpl.java:1418)
01-30 19:29:04.142: E/ActivityThread(21292): at android.app.ContextImpl.bindService(ContextImpl.java:1407)
01-30 19:29:04.142: E/ActivityThread(21292): at android.content.ContextWrapper.bindService(ContextWrapper.java:473)
01-30 19:29:04.142: E/ActivityThread(21292): at com.google.android.youtube.player.internal.r.e(Unknown Source)
01-30 19:29:04.142: E/ActivityThread(21292): at com.google.android.youtube.player.YouTubeThumbnailView.initialize(Unknown Source)
01-30 19:29:04.142: E/ActivityThread(21292): at com.reemdroid.tube.MainActivity.onCreate(MainActivity.java:131)
01-30 19:29:04.142: E/ActivityThread(21292): at android.app.Activity.performCreate(Activity.java:5104)
01-30 19:29:04.142: E/ActivityThread(21292): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
01-30 19:29:04.142: E/ActivityThread(21292): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
01-30 19:29:04.142: E/ActivityThread(21292): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
01-30 19:29:04.142: E/ActivityThread(21292): at android.app.ActivityThread.access$600(ActivityThread.java:141)
01-30 19:29:04.142: E/ActivityThread(21292): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
01-30 19:29:04.142: E/ActivityThread(21292): at android.os.Handler.dispatchMessage(Handler.java:99)
01-30 19:29:04.142: E/ActivityThread(21292): at android.os.Looper.loop(Looper.java:137)
01-30 19:29:04.142: E/ActivityThread(21292): at android.app.ActivityThread.main(ActivityThread.java:5039)
01-30 19:29:04.142: E/ActivityThread(21292): at java.lang.reflect.Method.invokeNative(Native Method)
01-30 19:29:04.142: E/ActivityThread(21292): at java.lang.reflect.Method.invoke(Method.java:511)
01-30 19:29:04.142: E/ActivityThread(21292): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
01-30 19:29:04.142: E/ActivityThread(21292): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
01-30 19:29:04.142: E/ActivityThread(21292): at dalvik.system.NativeStart.main(Native Method)
01-30 19:29:04.142: E/ActivityThread(21292): Activity com.reemdroid.tube.MainActivity has leaked ServiceConnection com.google.android.youtube.player.internal.r$e@42f2ed08 that was originally bound here
01-30 19:29:04.142: E/ActivityThread(21292): android.app.ServiceConnectionLeaked: Activity com.reemdroid.tube.MainActivity has leaked ServiceConnection com.google.android.youtube.player.internal.r$e@42f2ed08 that was originally bound here
01-30 19:29:04.142: E/ActivityThread(21292): at android.app.LoadedApk$ServiceDispatcher.<init>(LoadedApk.java:969)
01-30 19:29:04.142: E/ActivityThread(21292): at android.app.LoadedApk.getServiceDispatcher(LoadedApk.java:863)
01-30 19:29:04.142: E/ActivityThread(21292): at android.app.ContextImpl.bindService(ContextImpl.java:1418)
01-30 19:29:04.142: E/ActivityThread(21292): at android.app.ContextImpl.bindService(ContextImpl.java:1407)
01-30 19:29:04.142: E/ActivityThread(21292): at android.content.ContextWrapper.bindService(ContextWrapper.java:473)
01-30 19:29:04.142: E/ActivityThread(21292): at com.google.android.youtube.player.internal.r.e(Unknown Source)
01-30 19:29:04.142: E/ActivityThread(21292): at com.google.android.youtube.player.YouTubeThumbnailView.initialize(Unknown Source)
01-30 19:29:04.142: E/ActivityThread(21292): at com.reemdroid.tube.MainActivity.onCreate(MainActivity.java:133)
01-30 19:29:04.142: E/ActivityThread(21292): at android.app.Activity.performCreate(Activity.java:5104)
01-30 19:29:04.142: E/ActivityThread(21292): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
01-30 19:29:04.142: E/ActivityThread(21292): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
01-30 19:29:04.142: E/ActivityThread(21292): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
01-30 19:29:04.142: E/ActivityThread(21292): at android.app.ActivityThread.access$600(ActivityThread.java:141)
01-30 19:29:04.142: E/ActivityThread(21292): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
01-30 19:29:04.142: E/ActivityThread(21292): at android.os.Handler.dispatchMessage(Handler.java:99)
01-30 19:29:04.142: E/ActivityThread(21292): at android.os.Looper.loop(Looper.java:137)
01-30 19:29:04.142: E/ActivityThread(21292): at android.app.ActivityThread.main(ActivityThread.java:5039)
01-30 19:29:04.142: E/ActivityThread(21292): at java.lang.reflect.Method.invokeNative(Native Method)
01-30 19:29:04.142: E/ActivityThread(21292): at java.lang.reflect.Method.invoke(Method.java:511)
01-30 19:29:04.142: E/ActivityThread(21292): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
01-30 19:29:04.142: E/ActivityThread(21292): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
01-30 19:29:04.142: E/ActivityThread(21292): at dalvik.system.NativeStart.main(Native Method)
01-30 19:29:04.152: E/ActivityThread(21292): Activity com.reemdroid.tube.MainActivity has leaked ServiceConnection com.google.android.youtube.player.internal.r$e@42f2bf80 that was originally bound here
01-30 19:29:04.152: E/ActivityThread(21292): android.app.ServiceConnectionLeaked: Activity com.reemdroid.tube.MainActivity has leaked ServiceConnection com.google.android.youtube.player.internal.r$e@42f2bf80 that was originally bound here
01-30 19:29:04.152: E/ActivityThread(21292): at android.app.LoadedApk$ServiceDispatcher.<init>(LoadedApk.java:969)
01-30 19:29:04.152: E/ActivityThread(21292): at android.app.LoadedApk.getServiceDispatcher(LoadedApk.java:863)
01-30 19:29:04.152: E/ActivityThread(21292): at android.app.ContextImpl.bindService(ContextImpl.java:1418)
01-30 19:29:04.152: E/ActivityThread(21292): at android.app.ContextImpl.bindService(ContextImpl.java:1407)
01-30 19:29:04.152: E/ActivityThread(21292): at android.content.ContextWrapper.bindService(ContextWrapper.java:473)
01-30 19:29:04.152: E/ActivityThread(21292): at com.google.android.youtube.player.internal.r.e(Unknown Source)
01-30 19:29:04.152: E/ActivityThread(21292): at com.google.android.youtube.player.YouTubeThumbnailView.initialize(Unknown Source)
01-30 19:29:04.152: E/ActivityThread(21292): at com.reemdroid.tube.MainActivity.onCreate(MainActivity.java:132)
01-30 19:29:04.152: E/ActivityThread(21292): at android.app.Activity.performCreate(Activity.java:5104)
01-30 19:29:04.152: E/ActivityThread(21292): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
01-30 19:29:04.152: E/ActivityThread(21292): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
01-30 19:29:04.152: E/ActivityThread(21292): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
01-30 19:29:04.152: E/ActivityThread(21292): at android.app.ActivityThread.access$600(ActivityThread.java:141)
01-30 19:29:04.152: E/ActivityThread(21292): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
01-30 19:29:04.152: E/ActivityThread(21292): at android.os.Handler.dispatchMessage(Handler.java:99)
01-30 19:29:04.152: E/ActivityThread(21292): at android.os.Looper.loop(Looper.java:137)
01-30 19:29:04.152: E/ActivityThread(21292): at android.app.ActivityThread.main(ActivityThread.java:5039)
01-30 19:29:04.152: E/ActivityThread(21292): at java.lang.reflect.Method.invokeNative(Native Method)
01-30 19:29:04.152: E/ActivityThread(21292): at java.lang.reflect.Method.invoke(Method.java:511)
01-30 19:29:04.152: E/ActivityThread(21292): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
01-30 19:29:04.152: E/ActivityThread(21292): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
01-30 19:29:04.152: E/ActivityThread(21292): at dalvik.system.NativeStart.main(Native Method)
01-30 19:29:04.152: E/ActivityThread(21292): Activity com.reemdroid.tube.MainActivity has leaked ServiceConnection com.google.android.youtube.player.internal.r$e@42f51090 that was originally bound here
01-30 19:29:04.152: E/ActivityThread(21292): android.app.ServiceConnectionLeaked: Activity com.reemdroid.tube.MainActivity has leaked ServiceConnection com.google.android.youtube.player.internal.r$e@42f51090 that was originally bound here
01-30 19:29:04.152: E/ActivityThread(21292): at android.app.LoadedApk$ServiceDispatcher.<init>(LoadedApk.java:969)
01-30 19:29:04.152: E/ActivityThread(21292): at android.app.LoadedApk.getServiceDispatcher(LoadedApk.java:863)
01-30 19:29:04.152: E/ActivityThread(21292): at android.app.ContextImpl.bindService(ContextImpl.java:1418)
01-30 19:29:04.152: E/ActivityThread(21292): at android.app.ContextImpl.bindService(ContextImpl.java:1407)
01-30 19:29:04.152: E/ActivityThread(21292): at android.content.ContextWrapper.bindService(ContextWrapper.java:473)
01-30 19:29:04.152: E/ActivityThread(21292): at com.google.android.youtube.player.internal.r.e(Unknown Source)
01-30 19:29:04.152: E/ActivityThread(21292): at com.google.android.youtube.player.YouTubeThumbnailView.initialize(Unknown Source)
01-30 19:29:04.152: E/ActivityThread(21292): at com.reemdroid.tube.MainActivity.onCreate(MainActivity.java:145)
01-30 19:29:04.152: E/ActivityThread(21292): at android.app.Activity.performCreate(Activity.java:5104)
我错过了什么吗?我看到一个 serviceConnection,但我认为在发布 YouTubeThumbnailLoader 时它应该消失了。
最佳答案
每个 YouTubeThumbnailView
都有一个加载器。您只保存对其中之一的引用(在字段 this.Loader
中)并且您只释放那个加载程序。你想释放所有这些。
实现此目的的一种方法是保留从 YouTubeThumbnailView
到 YouTubeThumbnailLoader
的映射。在 onInitializationSuccess
中,您执行 map.put(view, loader)
并在 onClick
(您释放的位置)中调用 .release()
在 map.valueSet()
中的所有加载器上。
希望对您有所帮助!
关于android - 使用 YouTubeThumbnailViews 切换 Activity 时泄漏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14611876/
我最近在/ drawable中添加了一些.gifs,以便可以将它们与按钮一起使用。这个工作正常(没有错误)。现在,当我重建/运行我的应用程序时,出现以下错误: Error: Gradle: Execu
Android 中有返回内部存储数据路径的方法吗? 我有 2 部 Android 智能手机(Samsung s2 和 s7 edge),我在其中安装了一个应用程序。我想使用位于这条路径中的 sqlit
这个问题在这里已经有了答案: What's the difference between "?android:" and "@android:" in an android layout xml f
我只想知道 android 开发手机、android 普通手机和 android root 手机之间的实际区别。 我们不能从实体店或除 android marketplace 以外的其他地方购买开发手
自Gradle更新以来,我正在努力使这个项目达到标准。这是一个团队项目,它使用的是android-apt插件。我已经进行了必要的语法更改(编译->实现和apt->注释处理器),但是编译器仍在告诉我存在
我是android和kotlin的新手,所以请原谅要解决的一个非常简单的问题! 我已经使用导航体系结构组件创建了一个基本应用程序,使用了底部的导航栏和三个导航选项。每个导航选项都指向一个专用片段,该片
我目前正在使用 Facebook official SDK for Android . 我现在正在使用高级示例应用程序,但我不知道如何让它获取应用程序墙/流/状态而不是登录的用户。 这可能吗?在那种情
我在下载文件时遇到问题, 我可以在模拟器中下载文件,但无法在手机上使用。我已经定义了上网和写入 SD 卡的权限。 我在服务器上有一个 doc 文件,如果用户单击下载。它下载文件。这在模拟器中工作正常但
这个问题在这里已经有了答案: What is the difference between gravity and layout_gravity in Android? (22 个答案) 关闭 9
任何人都可以告诉我什么是 android 缓存和应用程序缓存,因为当我们谈论缓存清理应用程序时,它的作用是,缓存清理概念是清理应用程序缓存还是像内存管理一样主存储、RAM、缓存是不同的并且据我所知,缓
假设应用程序 Foo 和 Eggs 在同一台 Android 设备上。任一应用程序都可以获取设备上所有应用程序的列表。一个应用程序是否有可能知道另一个应用程序是否已经运行以及运行了多长时间? 最佳答案
我有点困惑,我只看到了从 android 到 pc 或者从 android 到 pc 的例子。我需要制作一个从两部手机 (android) 连接的 android 应用程序进行视频聊天。我在想,我知道
用于使用 Android 以编程方式锁定屏幕。我从 Stackoverflow 之前关于此的问题中得到了一些好主意,并且我做得很好,但是当我运行该代码时,没有异常和错误。而且,屏幕没有锁定。请在这段代
文档说: android:layout_alignParentStart If true, makes the start edge of this view match the start edge
我不知道这两个属性和高度之间的区别。 以一个TextView为例,如果我将它的layout_width设置为wrap_content,并将它的width设置为50 dip,会发生什么情况? 最佳答案
这两个属性有什么关系?如果我有 android:noHistory="true",那么有 android:finishOnTaskLaunch="true" 有什么意义吗? 最佳答案 假设您的应用中有
我是新手,正在尝试理解以下 XML 代码: 查看 developer.android.com 上的文档,它说“starStyle”是 R.attr 中的常量, public static final
在下面的代码中,为什么当我设置时单选按钮的外观会发生变化 android:layout_width="fill_parent" 和 android:width="fill_parent" 我说的是
很难说出这里要问什么。这个问题模棱两可、含糊不清、不完整、过于宽泛或夸夸其谈,无法以目前的形式得到合理的回答。如需帮助澄清此问题以便重新打开,visit the help center . 关闭 9
假设我有一个函数 fun myFunction(name:String, email:String){},当我调用这个函数时 myFunction('Ali', 'ali@test.com ') 如何
我是一名优秀的程序员,十分优秀!