Android网络收音机项目(源码实例分享)

<?xml version="1.0" encoding="utf-8"?

<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基础开发资料

详解:Linux网络虚拟化技术

分享内容包括不限于高级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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值