00:44
00:44

Gettting Illegal State Exception not attached to Activity

if you perform an AsyncTask and do some UI operations onPostExecute function, you may get this error.

To get rid of this error, write the code below

if (isDetached()) {
return;
}

at the top of your onPostExecute function.


17:10
17:10

How to fix a weird java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader

When building an android application, you can get this error when trying to load jni libs. The reason of this problem is one of the required library is not in the correct location. Please check once again the native libraries are in correct place. In this post, I am gonna tell one of the weird reason why a developer can get this error.

 
Think that, you have a project and you have armeabi libraries. (you don’t have any armeabi-v7a folder). If one of the libraries you have in project also uses native libraries and this project has armeabi-v7a folder. Then when you install the app on a armv7a architecture, android does not copy armeabi libraries in your other project and android expects all required libraries is under armeabi-v7a folder. So you get this unsatisfied link error. In short, if one of the library you have used in your project has both armeabi and armeabi-v7 folder, your other modules should also have the armeabi and armeabi-v7 folders with all requred libraries loaded separately.


11:35
11:35

Build your own security camera with Raspberry PI and watch&control it online

Today, we are going to let Raspberry PI turn into a remote security cam that we can control and watch live anywhere on the planet with using our mobile phone. This is the maker version of dropcam, nestcam, etc. We call it Butterfly PI.

To make things simple, we prepare a step by step guide so that any maker or developer can build his/her own remote security camera. Btw, if you just want to try your own camera, let us assemble the camera for you. Keep in touch contact@butterflytv.net Here is the outline, first, we need to make the mobile app ready for camera. Secondly, build the camera. Let me tell what we have needed for building the camera in advance.

  • Android Phone(4.0 or higher)
  • Raspberry PI 2
  • Raspberry Camera Module
  • Power Adapter 5V – 1A with micro USB output
  • USB Audio Adapter(Optional)
  • USB Wi-Fi dongle(Raspberry PI 2 compatible) and Ethernet Cable

Continue reading →


13:26
13:26

Live streaming from Ardrone 2.0


We can broadcast live from Ardrone 2.0 camera to Butterfly TV with Dronefly. Here is the source code https://github.com/ButterFly-Broadcast/Dronefly. New contributors are welcome.

Let me tell what Butterfly TV is. It is a Live Stream Messaging app that makes you share your moments instantly to Contacts or Social Media

Installation

Software is tested in Ubuntu.

  • Install ffmpeg (you can use apt-get) and make sure that ffmpeg executable is in your PATH. Because Dronefly directly use ffmpeg via Java Runtime

  • Check out the project from this repository and run it on Eclipse

Usage

  • PC needs two network interfaces. One is wi-fi interface for connecting to Ardrone and other one is any network interface for connecting internet.

  • We first connected ubuntu to Ardrone wi-fi hotspot and secondly we connected Android phone(with internet connection) to ubuntu via USB cable and enabled USB tethering.

Screenshot of Dronefly

  • Click “Connect Drone” then “Start Streaming” will be enabled. Write a stream name to text field and click “Start Streaming”. You can stop streaming when you hit the same button.

  • Right now you can control Ardrone with keyboard commands

    • Take off -> Enter
    • Landing -> Ctrl + Space
    • Hover -> Space
    • Forward -> Arrow Up
    • Backward -> Arrow Down
    • Left -> Arrow Left
    • Right -> Arrow Right
    • Spin Left -> Shift + Arrow Left
    • Spin Right -> Shift + Arrow Right
  • Use software with your own risk. There is no responsibility taken in any situation

Here are two videos first one is directly from Ardrone camera that was broadcasted live to Butterfly TV

Second video is the drone above while it was broadcasting

Reminder: Use this software with your own risk. There is no responsibility taken for any circumstances


06:57
06:57

How to play RTMP Stream in Android


I am one of the guys who need to play RTMP stream in Android to use in Butterfly TV project. As you know, Android’s VideoView does not support playing RTMP Streams.
I googled a lot to find out a blog post to solve this issue however no luck. There is no ultimate solution for this.

I tried the Vitamio player that can play RTMP stream theoretically but in reality it is not very succesfull. After that I found out Vitamio is not built with librtmp library which is a compatible library for almost all media servers so I understand that if I can compile Vitamio’s ffmpeg with librtmp, it can play the RTMP Streams in Red5 server. I learned how to compile Vitamio’s ffmpeg And I compiled the Vitamio’s ffmpeg with librtmp. It is available on Github.

As a result, if you use vitamio within this repo. You can play RTMP streams. Btw, if you use Red5 server and want to play live stream. You should add ” live=1″ at the end of the URL as it is described in README.md

This solution is used in Butterfly TV. You can check it out on Google Play Get it on Google Play


10:24
10:24

How to extract snapsot image from RTMP stream’s videodata in Red5 App

Most of the guys, developing red5 app, may need to have the snapshot of rtmp stream. I googled to find out a simple solution to use in Butterfly TV project One of the solution is to use ffmpeg via Runtime. I do not prefer red5 server to depend a third party executable. So I developed a different solution. I again have used ffmpeg but as a library in Red5 app. Let me show how. 

  • Download JavaCV. (I used JavaCV 0.8 version)
  • Exract to ffmpeg.jar, ffmpeg-linux-x86.jar, javacv.jar, javacpp.jar, opencv.jar, opencv-linux-x86.jar into the “WebContent/WEB-INF/lib/” of your Red5 application. (If your server is different from linux-x86, you should extract related jar according to your server OS and architecture)
  • Then we assume we already added listener for receiving packets on packetReceived function.
  • 
    public class SnapshotCreator {
    ByteArrayOutputStream tmpFlvStream = new ByteArrayOutputStream();
    int videoFrameCountForPreview = 0;
    
    public static String PREVIEW_DIRECTORY = "directroy you prefer";
    
    public String streamURL;
    
    public SnapshotCreator(String url) {
        this.streamURL = url;
        tmpFlvStream.write(getFLVHeader());
    }
    
    public void packetReceived(IBroadcastStream stream, IStreamPacket packet) {
    
        IoBuffer data = packet.getData().asReadOnlyBuffer().duplicate();
    
        if (data.limit() == 0) {
            System.out.println("data limit -> 0");
    	return;
        }
    	 <a href="http://www.gdgankara.org/blog/2014/11/07/how-to-extract-snapsot-image-from-rtmp-streams-videodata-in-red5-app/#more-249" class="more-link"><em>Continue reading &rarr;</em></a>

15:27
15:27

Export War file from Eclipse Web Project with Gradle

If you are a newbie about gradle and you need to export war file from Eclipse Web Project without changing anything in project layout, you may need to spend some more time after you study the Gradle Tutorials and War Plugin. Even if it is a small snippet, I spent some time so  think sharing simple gradle script to export war file from Eclipse web project may save time for some guys. Below lines are more meaningful after you read the Gradle Tutorials and War Plugin.

// we need to use war plugin
apply plugin: 'war'

//default webAppDirName in gradle is not "WebContent" but 
// it is default in eclise so change it according to eclipse layout
// it encapsulates all files under webAppDirName
webAppDirName = 'WebContent'

// build directory of gradle, it is default "build" and
// we don't need to change it. I changed because I dont want eclipse
// and gradle build to be mixed. 
buildDir = 'gradle_build'

// src is not default java source dir in gradle 
// so change srcDir and resources srcDir 
//according to eclipse project layout  
sourceSets {
  main {
     java {
	      srcDir 'src'
     }
     resources {
       srcDir 'src'
     }
  } 
}

//I have just realized that we did not need repositories definiton below
//But it should be tested again after removing below lines
repositories {
   flatDir { dirs "WebContent/WEB-INF/lib","libs"}
}

// In eclipse project, we generally add all dependecies under
//WEB-INF/lib for runtime.
// I also used libs directory for only compile time,
// we added two directory below to make gradle build successfully.
//It is defined as "providedCompile" which says gradle that do not 
//add these libraries to
//war file explicitly because it will be available in runtime.
//btw, we already let gradle add all files to war under WebContent 
dependencies {
  providedCompile fileTree(dir:'WebContent/WEB-INF/lib', include:'*.jar')
  providedCompile fileTree(dir:'libs', include:'*.jar')
}

here is the gist link


22:34
22:34

“Package file was not signed correctly” on Nexus 7 Android 4.4.2 Kitkat

I develop an app, test it on my nexus 7 and after that i  uploaded to Google play. When try to download app to Nexus 7, it says that “Package file was not signed correctly. Uninstall the previous app”. Yeah it is a message that you encounter when you forget to uninstall the debug version of the app. But what if you already removed the app and it can be installed to other devices like HTC One X (Cyanogenmod 10.1.3)

General solution of “Package file was not signed correctly” problem is on this blog post.

However it doesn’t work for me.

Actually,  solution for me is simpler but it took some time to find it.  Just remove the app via adb from your device like below

adb uninstall com.butterfly

I hope this post may save some of your time.


00:17
00:17

How to resolve “This project has the JPA facet, but no JPA project could be created.” and ‘Console configuration “null” does not exist.’ for Butterfly Project

We use Hibernate so first let’s install JBoss tools from update site below

http://download.jboss.org/jbosstools/updates/stable/kepler/

  • Write “hibernate” in filter box and then select all items after filterins is done and finish JBoss plugin installation
  • After plugin installation finishes, Click “Window > Show View > Other ..” then select “Hibernate Configuration” view
  • Click “+” button to add a new configuration.
  • Then fill the window like below. (Select the project you define configuration for)

bb Continue reading →


21:34
21:34

How to resolve “Target Red5 Server Runtime is undefined” for Butterfly Project

If you encounter the that Target Runtime Red5 is undefined for your eclipse project. It’s likely that you didn’t install Eclipse Red5 Plugin and didn’t add Red5 Runtime.

  • First install Red5 Plugin to eclipse via below update site.

Name: Red5Plugin 0.2.x (Eclipse 3.2+) URL: http://www.red5.org/downloads/projects/red5plugin/update_0.2.x/

  • After that click “Run” button in eclise toolbar. Select “Run on Server” and click “Ok” button
  • Select Red5 Server Runtime in the coming window
  • Define Red5 Runtime Continue reading →