Category Archives: dev

Store Drawable extracted from ImageView of another app(another developer’s) as a file.

Store Drawable extracted from ImageView of another app(another developers) as a file, and send the file Uri.

                             contactDrawable = MyUtil.extractImage(context, root);
                             Bitmap bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(),
                                           drawable.getIntrinsicHeight(), Config.ARGB_8888);
                             Canvas canvas = new Canvas(bitmap);
                             drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
                             drawable.draw(canvas);
                                   if (drawable instanceof BitmapDrawable) {
                                 bitmap = ((BitmapDrawable)drawable).getBitmap();
                             }
                                
                                 try {
                                         String extStorageDirectory = Environment.getExternalStorageDirectory
                                                                   ().toString();
                                        
                                         File mDir = new File(extStorageDirectory + “/SW2Line/”);
                                         if(!mDir.exists())
                                                mDir.mkdir();
                                        
                                        
                                     FileOutputStream out = new FileOutputStream(extStorageDirectory +
                                              “/SW2Line/tempProfile.png”);
                                     bitmap.compress(Bitmap.CompressFormat.PNG, 90, out);
                                     
                                     out.flush();
                                     out.close();
                                     
                                     contactIcon = Uri.fromFile(new File(extStorageDirectory +
                                               “/SW2Line/tempProfile.png”)).toString();
                                     
                                     LogControl.i(TAG,“out toString = “ + contactIcon );
                                 } catch (Exception e) {
                                     e.printStackTrace();
                                 }
                         }catch(Exception e) {e.printStackTrace(); contactIcon = “”;}

Extract a Instance of specific class RemoteViews which don’t know to how to make.

Extract a Instance of specific class RemoteViews which I don’t know to how to make.


Return instance that i’m looking for.

If type == 0, then return a instance first found.
If type == 1, then return a instance second found.


The problem is, because of tree search, maybe return different value depending on the situation.



ex) find a instance of TextView in RemoteViews.

count is a static variable.


      static public TextView extractTextView(Context context, RemoteViews views, int type) {
           
        Context remotePackageContext ;
        remotePackageContext  = context.getApplicationContext();
        try{
              remotePackageContext = context.createPackageContext(TARGET_PACKAGE, 0);
        }catch(Exception e){;}
       
        LinearLayout ll = new LinearLayout(remotePackageContext );
        View view = views.apply(remotePackageContext, ll);
        count = 0;
       
        LogControl.i(TAG, “msg = ” + searchForTextView(view,2).getText().toString());
        count = 0;
       
        return searchForTextView(view,type);
    }
     
     
    static public TextView searchForTextView(View view, int duration) {
        if (view instanceof TextView) {
              TextView textView = (TextView)view;
              String text = textView.getText().toString();
              count ++;
              LogControl.i(TAG, “tview string = ” + text);
             
              if(textView.getTag() == null && count > duration){
                  
                   return (TextView)view;
              }
        }

        if (view instanceof ViewGroup) {
            ViewGroup viewGroup = (ViewGroup) view;
            for (int i = 0; i < viewGroup.getChildCount(); i++) {
                TextView result = searchForTextView(viewGroup.getChildAt(i), duration);
                if (result != null) {
                     if(count > duration)
                           return result;
                }
            }
        }
        return null;
    }

Subscribe the notification of another app. #2

Case of Hangouts, if a user not check the notification of Hangouts,
receive message like “2 unread message.” without real content.
Only Hangouts…

Therefore, when receive a notification every time, i’ll clear the notification.

Available access the context of another application. But can’t modify.
If modified that, it caused Security Exception.

call cancel() in notificationManager of remote context….

10-27 12:22:09.525: E/AndroidRuntime(5055): java.lang.RuntimeException: Unable to start receiver com.mypackage.MyReceiver: java.lang.SecurityException: Calling uid 10141 gave package com.kakao.talk which is owned by uid 10152

I tried googling hard… but coundn’t.
Finally, I found it.
notification.deleteIntent.send(context,0,new Intent());
Add just one line like this.
In addition, run the notification by “notification.contentIntent”

Subscribe notification of another app. #1

Finally came up here doing connect to messanger because buy the Sony SW2…

1. Register accessibility service
register accessibility service, then achive the permission.
can access the notification of another application.

Accessibility service became run, if register manifest.xml only.
but, if two or more accessility service require same permission,
that’s maybe impossible.

Therefore, one accessilibty service broadcast to another apps.

In manifest.xml
  <serviceandroid:name=“com.mypackage.MyAccessibilityService”
        android:permission=“android.permission.BIND_ACCESSIBILITY_SERVICE”>
    <intent-filter>
        <actionandroid:name=“android.accessibilityservice.AccessibilityService”/>
      intent-filter>
      <meta-data
            android:name=“android.accessibilityservice”
            android:resource=“@xml/accessibilityservice”/>
   </service>

Make meta-data with xml

in acessibilityservice.xml
<accessibility-servicexmlns:android=“http://schemas.android.com/apk/res/android”
    android:accessibilityEventTypes=“typeNotificationStateChanged”
    android:accessibilityFeedbackType=“feedbackAllMask”
    android:notificationTimeout=“100”/>

AccessilibtyEventType must not duplicated maybe…