2017년 10월 27일 금요일

안드로이드 Intent ACTION_VIEW 외부 크롬 브라우저 호출


안드로이드 Intent ACTION_VIEW 외부 크롬 브라우저 호출


String parmUnit = aplMy.getSContactDomain();
parmUnit = parmUnit + "mobile_svc/android/board/b_modify.php";
parmUnit = parmUnit + "?board_number="+sMltUrl[1]+"&login_id="+sMltUrl[2]+"&login_seq="+sMltUrl[3]+"&seq="+sMltUrl[4];

callChromeBrowser(parmUnit);

==============================================

//외부브라우저인 크롬 브라우저 호출
public void callChromeBrowser(String url){   
//Chrome Browser Package name
String packageName = "com.android.chrome";                   

Intent i = new Intent(Intent.ACTION_VIEW);
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
i.setPackage(packageName);
i.setData(Uri.parse(url));

//Chrome Browser가 설치되어있으면 Call, 없으면 마켓으로 Install               
List<ResolveInfo> activitiesList = getPackageManager().queryIntentActivities(i, -1);
if(activitiesList.size() > 0) {
startActivity(i);
} else {
Intent playStoreIntent = new Intent(Intent.ACTION_VIEW);
playStoreIntent.setData(Uri.parse("market://details?id="+packageName));
playStoreIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(playStoreIntent);
}
}

ACTION_VIEW만 하면 브라우저 목록들이 뜨는데, 크롬브라우저 지정하면 크롬브라우저가 호출이 되어 호출하는 단계가 줄어들어 더 편리해져요

크롬브라우저가 없으면 설치하러 플레이스토어를 통하여 설치하러 이동하고, 있으면 크롬 브라우저를 호출한다

Have a nice day~


2017년 10월 15일 일요일

c#에서 webbrowser 적용시 Internet explorer의 버전 올리기 [현재 시스템에서 사용중인 버전으로 수정하기]


c#에서 webbrowser 적용시 Internet explorer의 버전 올리기 [현재 시스템에서 사용중인 버전으로 수정하기]

기본적으로 시샵에서 Internet Explorer 7 버전이 탑재되어 있어요
몇년도에 만들어진 버전인지 모르지만 아주 오래된 버전이고, 현재 시점에는 Internet Explorer 11점 대가 사용되고 있어요

수정하기 위해서는 레지스트리 값을 수정해 주셔야 해요

소스)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;

//웹브라우저 레지스트리 등록하는 부분
//(x)  http://guideme.tistory.com/1
//(ㅇ) http://okgood0412.tistory.com/entry/C-WebBrowser-version-%EB%B3%80%EA%B2%BD

using System.Security;
using Microsoft.Win32;
using System.IO;
using System.Threading;
using System.Diagnostics;

namespace Test5
{
    static class Program
    {
        static Mutex mutex = new System.Threading.Mutex(false, "jMutex");
   
        /// <summary>
        /// 해당 응용 프로그램의 주 진입점입니다.
        /// </summary>
        [STAThread]
        static void Main()
        {
           

            //SetBrowserEmulationVersion();

            if (!mutex.WaitOne(TimeSpan.FromSeconds(2), false))

            {

                //another application instance is running

                return;

            }



            try

            {

                Application.EnableVisualStyles();

                Application.SetCompatibleTextRenderingDefault(false);



                var targetApplication = Process.GetCurrentProcess().ProcessName + ".exe";

                int browserver = 7;

                int ie_emulation = 11999;



                using (WebBrowser wb = new WebBrowser())

                {

                    browserver = wb.Version.Major;





                    if (browserver >= 11)

                        ie_emulation = 11001;

                    else if (browserver == 10)

                        ie_emulation = 10001;

                    else if (browserver == 9)

                        ie_emulation = 9999;

                    else if (browserver == 8)

                        ie_emulation = 8888;

                    else

                        ie_emulation = 7000;

                }



                try

                {

                    //string tmp = Properties.Settings.Default.Properties.

                    SetIEVersioneKeyforWebBrowserControl(targetApplication, ie_emulation);

                    Application.Run(new Form1());



                }

                catch (Exception ex1)

                {



                }



            }

            catch (Exception ex2)

            {





            }
            finally

            {

                mutex.ReleaseMutex();

            }

        }



        private static void SetIEVersioneKeyforWebBrowserControl(string appName, int ieval)

        {

            RegistryKey Regkey = null;

            try

            {

                Regkey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION", true);



                //If the path is not correct or

                //If user't have priviledges to access registry

                if (Regkey == null)

                {

                    MessageBox.Show("Application FEATURE_BROWSER_EMULATION Failed - Registry key Not found");

                    return;

                }



                string FindAppkey = Convert.ToString(Regkey.GetValue(appName));



                //Check if key is already present

                if (FindAppkey == ieval.ToString())

                {

                    MessageBox.Show("Application FEATURE_BROWSER_EMULATION already set to " + ieval);

                    Regkey.Close();

                    return;

                }



                //If key is not present or different from desired, add/modify the key , key value

                Regkey.SetValue(appName, unchecked((int)ieval), RegistryValueKind.DWord);



                //check for the key after adding

                FindAppkey = Convert.ToString(Regkey.GetValue(appName));



                if (FindAppkey == ieval.ToString())

                {

                    MessageBox.Show("Application FEATURE_BROWSER_EMULATION changed to " + ieval + "; changes will be visible at application restart");

                }

                else

                {

                    MessageBox.Show("Application FEATURE_BROWSER_EMULATION setting failed; current value is  " + ieval);

                }

            }

            catch (Exception ex)

            {

                MessageBox.Show("Application FEATURE_BROWSER_EMULATION setting failed; " + ex.Message);

            }

            finally

            {

                //Close the Registry

                if (Regkey != null)

                    Regkey.Close();

            }



            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form1());

        } // end main();
       











       
       
    }
}





2017년 10월 13일 금요일

c# 시샵에서 구글 크롬브라우저 띄우기 ( google chrome browser )


c# 시샵에서 구글 크롬브라우저 띄우기 

1) 비주얼 스튜디오 커뮤니티 버전으로 시샵으로 프로젝트 생성
    Visual studio community

Cefsharp 라이브러리 추가

2) 설정사항
닷넷 프레임워크 4.5.2 이상으로 실행 (.Net Framework 4.5 higher )
cpu x64로 실행

3) 기본적으로 영어로 실행
언어셋 변경

여러가지는 해보시면서 업데이트 하세요~

have a nice day~