<LinearLayout xmlns:android=http://schemas.android.com/apk/res/android]http://schemas.android.com/apk/res/android
android:orientation=“vertical”
android:layout_width=“fill_parent”
android:layout_height=“fill_parent”
<Button
android:id=“@+id/btn_start”
android:layout_gravity=“center_horizontal”
android:layout_width=“match_parent”
android:layout_height=“wrap_content”
android:text=“听猫扑”
android:textSize=“30sp”
android:onClick=“doStart”
/>
<Button
android:id=“@+id/btn_stop”
android:layout_gravity=“center_horizontal”
android:layout_width=“match_parent”
android:layout_height=“wrap_content”
android:text=“不听猫扑”
android:textSize=“30sp”
android:onClick=“doStop”
/>
**第一个activity代码,主要负责检查插件NetRadioDemoActivity
Java代码**
package com.netradiodemo;
import io.vov.vitamio.VitamioInstaller;
import io.vov.vitamio.VitamioInstaller.VitamioNotCompatibleException;
import io.vov.vitamio.VitamioInstaller.VitamioNotFoundException;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.LinearLayout.LayoutParams;
import android.widget.TextView;
import android.widget.Toast;
import com.netradiodemo.compnents.PlayerActivity;
public class NetRadioDemoActivity extends Activity {
Intent intent ;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
intent = new Intent(this, PlayerActivity.class);
TextView tvCheck = new TextView(this);
tvCheck.setText(“使用前请检查是否安装了Vitamio插件:”);
this.addContentView(tvCheck, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
Button btnCheck = new Button(this);
btnCheck.setText(“检查”);
btnCheck.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
try {
String isInstallerString = VitamioInstaller.checkVitamioInstallation(NetRadioDemoActivity.this);//检查插件是否安装成功,这里是一个费时操作,应该启新线程处理,作为一个demo我就不做了
Log.i(“tag”,isInstallerString); //插件安装成功后,Log中显示插件名称
if(isInstallerString!=null){
Toast.makeText(NetRadioDemoActivity.this, “已安装正确版本Vitamio!”, Toast.LENGTH_LONG).show();
startActivity(intent);//开启收听界面
}else{
Toast.makeText(NetRadioDemoActivity.this, “没有匹配的Vitamio!”, Toast.LENGTH_LONG).show();
finish();//没有插件安装失败,则结束程序
}
} catch (VitamioNotCompatibleException e) {
e.printStackTrace();
} catch (VitamioNotFoundException e) {
e.printStackTrace();
}
}
});
this.addContentView(btnCheck, new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
最后
分享一份NDK基础开发资料
分享内容包括不限于高级UI、性能优化、架构师课程、NDK、混合式开发(ReactNative+Weex)微信小程序、Flutter等全方面的Android进阶实践技术;希望能帮助到大家,也节省大家在网上搜索资料的时间来学习,也可以分享动态给身边好友一起学习!
加入社区》https://bbs.csdn.net/forums/4304bb5a486d4c3ab8389e65ecb71ac0
img-MqXj761R-1725747363442)]
分享内容包括不限于高级UI、性能优化、架构师课程、NDK、混合式开发(ReactNative+Weex)微信小程序、Flutter等全方面的Android进阶实践技术;希望能帮助到大家,也节省大家在网上搜索资料的时间来学习,也可以分享动态给身边好友一起学习!
加入社区》https://bbs.csdn.net/forums/4304bb5a486d4c3ab8389e65ecb71ac0